akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=acos(-1.0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,a,b;cin>>n>>a>>b;
    ll ans=0;
    ll now;cin>>now;
    rep(i,1,n){
        ll x;cin>>x;
        ll dis=(x-now)*a;
        ans+=min(dis,b);
        now=x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> T GCD(T a, T b) {
    if (b == 0) return a;
    if (a % b == 0) return b;
    return (GCD(b, a % b));
}
template<typename T> T LCM(T a, T b) {
    return (a/GCD(a,b)*b);
}
template<class T, class U> struct SegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(T, U)>;
    int n;
    T id;
    vector<T> data;
    F f;
    G g;
    
    SegmentTree(int sz, F f, G g, T def) : f(f), g(g) {
        n = 1; id = def;
        while (n < sz) n *= 2;
        data = vector<T>(2*n-1, id);
    }
    void update (int i, T x) {
        i += n - 1;
        data[i] = g(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return data[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

bool is_ok(vector<long long> A) {
    vector<int> cnt(A.size(), 0);
    for (int i = 0; i < A.size(); i++) {
        while (A[i]%2 == 0) {
            A[i] /= 2;
            cnt[i]++;
        }
    }
    sort(cnt.begin(), cnt.end());
    return (cnt[0] == cnt[(int)cnt.size()-1]);
}

signed main() {
    int N; long long M;
    cin >> N >> M;
    auto f = [](long long a, long long b) { return LCM(a, b); };
    auto g = [](long long a, long long b) { return b; };
    SegmentTree<long long, long long> sg(N, f, g, 1);
    SegmentTree<long long, long long> G(N, f, g, 1);
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        //sg.update(i, A[i]);
        G.update(i, (A[i]/2));
    }
    if (is_ok(A) == false) { cout << 0 << endl; return 0; }
    long long L = sg.query(0, N); // 全体のLCM
    //long long K = G.query(0, N);  // 全体の半公倍数
    //long long K = L/2;
    //cout << L << " " << K << endl;
    long long K = 1;
    for (auto a : A) {
        a /= 2;
        K = LCM(K, a);
        if (M < K) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (M < K) cout << 0 << endl;
    else {
        long long ans = ((M-K)/K)/2+1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,C[200007],ANS;

map<ll,ll> M;

int main(){
  ll sum=0;
  ll N,K;
  cin >> N >> K;
  M[0]++;
  if(K-1<=200006){
    C[K-1]=sum;
  }
  rep(i,N){
    cin >> A;
    sum+=A-1;
    sum%=K;
    M[sum]++;
    if(i>=K-1){
      M[C[i]]--;
    }
    if(i+K<=200006){
      C[i+K]=sum;
    }
    ANS+=M[sum]-1;
    //cout << sum  << M[0] << M[3]<< endl;
  }
  cout << ANS << endl;
}


Measured memory_bytes: 16072
from sys import stdin, stdout
import math
import bisect
import re

x = int(stdin.readline().strip())

for a in range(-500, 500):
    for b in range(-500, 500):
        if a ** 5 - b ** 5 == x:
            stdout.writelines(str(a) + ' ' + str(b) + '\n')
            exit(0)

Measured memory_bytes: 68692
#include <cstdio>
int main(){
	int a,b,c;
	int sum;
	char grade;
	while(1){
		scanf("%d%d%d",&a,&b,&c);
		if(a+b+c==-3) break;

		if(a==-1||b==-1) grade = 'F';
		else{
			sum = a+b;
			if(sum<30) grade = 'F';
			else if(sum<50){
				if(c>=50) grade = 'C';
				else grade = 'D';
			}
			else if(sum<65) grade = 'C';
			else if(sum<80) grade = 'B';
			else grade = 'A';
		}
		printf("%c\n",grade);
	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;

int main() {
  int n,k;
  cin >> n >> k;
  VI h(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  for(int i=0;i<n;i++){
    if(h.at(i)>=k){
      ans++;
    }
  }
  cout << ans <<endl;
      
  
  
      
      
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  // 東に向いている人の累積和
  // 西に向いている人の累積和
  vector<int> cs_east(N + 1, 0);
  vector<int> cs_west(N + 1, 0);
  for (int i = 0; i < N; i++) {
    int is_east = (S.at(i) == 'E');
    int is_west = (S.at(i) == 'W');
    cs_east.at(i + 1) = cs_east.at(i) + is_east;
    cs_west.at(i + 1) = cs_west.at(i) + is_west;
  }

  int ans = N;
  for (int i = 0; i < N; i++) {
    int from_west_to_east = cs_west.at(i);
    int from_east_to_west = cs_east.at(N) - cs_east.at(i + 1);
    int num = from_west_to_east + from_east_to_west;
    ans = min(ans, num);
  }

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


Measured memory_bytes: 6148
#include <stdio.h>

int main()
{
    int N;
    int H[20];
    int ans;
    int i,j;

    scanf("%d\n",&N);

    for(i=0;i<N;i++){
        if(i<N-1){
            scanf("%d ",&H[i]);
        }
        else{
            scanf("%d\n",&H[i]);            
        }
    }

    ans=1;

    for(i=1;i<N;i++){
        for(j=0;j<i;j++){
            if(H[j]>H[i]){
                break;
            }
        }
        if(j==i){
            ans=ans+1;
        }
    }

    printf("%d\n",ans);


    return 0;
}

Measured memory_bytes: 128
N = int(input())

count = 0
both = 0
forward = 0
backward = 0
for i in range(N):
    tmp = list(input())
    if tmp[0] == 'B' and tmp[-1] == 'A':
        both += 1
    elif tmp[0] == 'B' and tmp[-1] != 'A':
        forward += 1
    elif tmp[0] != 'B' and tmp[-1] == 'A':
        backward += 1
    for i in range(len(tmp) - 1):
        if tmp[i] == 'A' and tmp[i + 1] == 'B':
            count += 1

# print ('both', both)
# print ('forward', forward)
# print ('backward', backward)
# print ('count', count)

count += max(0, both - 1)
if both > 0:
    if forward > 0 and backward > 0: #前後どちらも埋めることができる
        forward -= 1
        backward -= 1
        count += 2
    elif forward > 0 and backward == 0: #前しか埋めることができない
        count += 1
        forward -= 1
    elif forward == 0 and backward > 0: #後ろしか埋めることができない
        count += 1
        backward -= 1
count += min(forward, backward)
print (count) 

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  int N, M, S{};
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    S += T[i];
  }

  cin >> M;
  int P, X;
  for (int i = 0; i < M; i++) {
    cin >> P >> X;
    cout << S - T[P-1] + X << endl;
  }

  return 0;
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	string str = to_string(N);
	int sum = 0;
	for (int i = 0; i < str.length(); ++i) {
		sum += (int)(str[i] - '0');
	}
	if (N%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long s = sc.nextLong();
			long w = sc.nextLong();
			System.out.println(s <= w ? "unsafe" : "safe");
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Measured memory_bytes: 35768
#!/usr/bin/env python3
import sys
import heapq

MOD = 1000000007  # type: int

def containPositive(arr):
    for a in arr:
        if a >= 0:
            return True
    return False

def solve(N: int, K: int, A: "List[int]"):
    if N == K:
        m = 1
        for a in A:
            m = m*a%MOD
        print(m)
    elif not containPositive(A):
        A = list(reversed(sorted(A))) if K%2 == 1 else list(sorted(A))
        m = 1
        for i in range(K):
            m = m*A[i]%MOD
        print(m)
    else:
        m = 1
        B = [(abs(a),a) for a in A]
        B = list(reversed(sorted(B)))
        lastNegative = 0
        lastPositive = 1
        hadPositive = False
        for i in range(K):
            a = B[i][1]
            if a < 0:
                if lastNegative == 0:
                    lastNegative = a
                else:
                    m = m*lastNegative*a%MOD
                    lastNegative = 0
            else:
                if a > 0 and lastPositive != 1:
                    m = m*lastPositive%MOD
                if a > 0:
                    lastPositive = a
                    hadPositive = True
                else:
                    m=m*a%MOD
        if lastNegative == 0:
            print(m*lastPositive%MOD)
        else:
            nextNegative = 0
            for i in range(K,N):
                b = B[i][1]
                if b < 0:
                    nextNegative = b
                    break
            if nextNegative == 0:
                m = m*B[K][1]
                print(m*lastPositive%MOD)
            else:
                c1 = lastNegative*nextNegative
                nextPositive = 0
                k = K
                while k < N:
                    a = B[k][1]
                    if a >=0:
                        nextPositive = a
                        break
                    k+=1
                c2 = nextPositive*lastPositive
                if not hadPositive: # This array contain some non-negative value. This means the result value could be positive. But if there were no positive values in the first K values sorted by the absolute value, use just next positive value instead of the last negative values.
                    m = m*nextPositive%MOD
                    print(m)
                    exit()
                if c1 > c2:
                    m = m*lastNegative*nextNegative%MOD
                    print(m)
                else:
                    m =m*nextPositive*lastPositive%MOD
                    print(m)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

#define ld long double
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define nl endl
#define pii pair <ll, ll>
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846264
#define y1 abacaba
#define fn "abc"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define chill_wave ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pressF freopen("flusha.in", "r", stdin); freopen("flusha.out", "w", stdout);

using namespace std;

const long long MXN = 1e6 + 1;
const long long MAXN = 1e2 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

inline void JUDGE(bool ok = 0) { chill_wave if(ok) { pressF; } }

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

ll n, a[MXN], ans;

int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}

int main () {

    JUDGE();

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[i] % 2 == 0) {
            while(a[i] % 2 == 0) {
                ans ++;
                a[i] /= 2;
            }
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=LLONG_MAX;
struct segtree
{
    vector<ll> node;
    vector<ll> lazy;
    vector<bool> lflg;
    int n;
    segtree(int sz)
    {
        n=1;while(n<sz) n*=2;
        node.resize(2*n,0);
        lazy.resize(2*n,0);
        lflg.resize(2*n,false);
    }
    void lazyupdate(int k, int l, int r)
    {
        if(lflg[k])
        {
            node[k]+=lazy[k];
            push(lazy[k],k,l,r);
            lazy[k]=0;
            lflg[k]=false;
        }
    }
    void push(int v,int k,int l,int r)
    {
        if(r-l>0)
        {
            lazy[2*k]+=v;
            lazy[2*k+1]+=v;
            lflg[2*k]=lflg[2*k+1]=true;
        }
    }
    void update(int qa, int qb, int v, int k=1, int l=1,int r=-1)
    {
        if(r<0) r=n;
        lazyupdate(k, l, r);
        if(qb<l||r<qa) return;
        if(qa<=l&&r<=qb)
        {
            node[k]+=v;
            push(v,k,l,r);
        }
        else
        {
            int m=(l+r)/2;
            update(qa,qb,v,2*k,l,m);
            update(qa,qb,v,2*k+1,m+1,r);
            node[k]=min(node[2*k],node[2*k+1]);
        }
    }
    ll get(int qa, int qb, int k=1, int l=1, int r=-1)
    {
        if(r<0) r=n;
        lazyupdate(k ,l, r);
        if(qb<l||r<qa) return INF;
        if(qa<=l&&r<=qb) return node[k];
        else
        {
            int m=(l+r)/2;
            ll lv=get(qa, qb, 2*k, l, m);
            ll rv=get(qa, qb, 2*k+1, m+1, r);
            return min(lv,rv);
        }
    }
};

int main()
{
    int n,q;
    scanf("%d %d",&n,&q);
    segtree tree(n);
    for(int i=0;i<q;i++){
        int c;
        scanf("%d",&c);
        if(c){
            int x,y;
            scanf("%d %d",&x,&y);
            cout<<tree.get(x+1,y+1)<<endl;
        }else{
            int s,t,v;
            scanf("%d %d %d",&s,&t,&v);
            tree.update(s+1,t+1,v);
        }
    }
}


Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
vector<string>s;

int calc(int a, int b, char c){
    switch (c){
        case '+': return a+b;
        case '*': return a*b;
    }
}

int calc_rec(int depth, int cur){
    char c=s[cur][depth];
    int res=0;
    if(c=='+'||c=='*'){
        int tmp;
        if(c=='*')res=1;
        int cur2=cur+1;
        while(cur2<s.size()&&s[cur2].size()>=depth+2){
            if(s[cur2][depth+1]!='.'){
                tmp=calc_rec(depth+1,cur2);
                res=calc(res,tmp,c);
            }
            cur2++;
        }
    }else res=int(c-'0');
    // printf("char : %c\n",c);
    // printf("return : %d\n",res);
    return res;
}

int main(void){
    while(true){
        int n;
        cin>>n;
        // printf("input\n");
        if(n==0)return 0;
        for(int i=0;i<n;i++){
            string tmp;
            cin >> tmp;
            s.push_back(tmp);
        }
        // printf("s size : %d\n",s.size());
        int res=calc_rec(0,0);
        cout << res << endl;
        if(!s.empty())s.clear();
    }
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;


long long int a,b,c[110],d[100010],ans =1,ant=1;

int main(){
  cin >> a >>b;
  
    if(abs(a-b) >1){
      cout << "0" <<endl;
    }
  
  else{
    
    if(abs(a-b) ==1){
      
      for(int i=1;i<=a;i++){
        ans *= i;
        ans %=1000000007;
      }
      for(int i=1;i<=b;i++){
        ans *=i;
        ans %=1000000007;
      }
      cout << ans << endl;
    }
    
    else{
      
        for(int i=1;i<=a;i++){
        ans *= i;
        ans %= 1000000007;
      }
      for(int i=1;i<=b;i++){
        ans *=i;
        ans %= 1000000007;
      }
      ans *= 2;
      ans %= 1000000007;
      cout << ans << endl;
    }
    }
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

a,b,c,x,y = map(int, input().split())

ans = []

c_max_num = max(x,y)*2

for c_num in range(c_max_num+1):
    a_num = max(0, x - c_num//2)
    b_num = max(0, y - c_num//2)

    tmp = a*a_num + b*b_num + c*c_num
    ans.append(tmp)


print(min(ans))





Measured memory_bytes: 16792
program abc_a
  character(1) nuc
  read *, nuc
  select case(nuc)
    case ('A')
      print '(A)', 'T'
    case ('T')
      print '(A)', 'A'
    case ('C')
      print '(A)', 'G'
    case ('G')
      print '(A)', 'C'
  end select
end program


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
 if(a <= c){
     if(a < c && b < c)
     cout << 0 << endl;
     else if(b < d)
     {
         cout << b - c << endl;
     }
     else
     {
         cout << d - c << endl;
     }
     
 }
else
{
    if(c < a && d < a)
    cout << 0 << endl;
    else if(b > d)
    {
        cout << d - a << endl;
    }
    else
    {
        cout << b - a << endl;
    }
    
    
}

}

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

struct Node{
    int key;
    Node *prev,*next;
};
Node* nill;

void init(){
    nill=(Node*)malloc(sizeof(Node));
    nill->prev=nill;
    nill->next=nill;
}

void insertkey(int key){
    Node* node=(Node*)malloc(sizeof(Node));
    node->key=key;
    nill->next->prev=node;
    node->prev=nill;
    node->next=nill->next;
    nill->next=node;
}
void deleteFirst(){
    Node* p;
    p=nill->next;
    nill->next=p->next;
    p->next->prev=nill;
    free(p);
}
void deleteLast(){
    Node* p;
    p=nill->prev;
    p->prev->next=nill;
    nill->prev=p->prev;
    free(p);
}
Node* find(int key){
    Node* p=nill->next;
    while(p!=nill){
        if(p->key==key)break;
        p=p->next;
    }
    return p;
}

void deletekey(int key){
    Node* p=find(key);
    if(p==nill)return;
    p->next->prev=p->prev;
    p->prev->next=p->next;
    free(p);
}
void printList(){
    Node* p=nill->next;
    while(p!=nill){
        if(p!=nill->next)printf(" ");
        printf("%d",p->key);
        p=p->next;
    }
    printf("\n");
}

int main(){
    init();
    int n,key;
    cin>>n;
    char query[20];
    for(int i=0;i<n;i++){
        scanf("%s",query);
        if(query[0]=='i'){
            scanf("%d",&key);
            insertkey(key);
        }
        else if(query[6]=='\0'){
            scanf("%d",&key);
            deletekey(key);
        }
        else if(query[6]=='F')deleteFirst();
        else deleteLast();
    }
    printList();
}


Measured memory_bytes: 34396
#include <bits/stdc++.h>
int main(int argc, char** argv)
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin >> n;
    cin.ignore();
    getline(cin, s);
    cout << (s.find('Y') == std::string::npos ? "Three\n" : "Four\n");
    return 0;
}

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  int m = 10000;
  int ans = 0;
  for (int i = -100; i < 200; i++) {
    if (abs(X - i) < m) {
      bool flag = true;
      for (int j = 0; j < N; j++) {
        if (i == p[j]) flag = false;
      }
      if (!flag) continue;
      ans = i;
      m = abs(X - i);
    } else {
      continue;
    }
  }

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

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
    int N,D;
    scanf("%d %d",&N,&D);
    int i,j;
    int X[10][10];
    //X = (int **)malloc(N*sizeof(int));
    //for(i=0;i<N;i++){
      //  X[i]= (int *)malloc(D*sizeof(int));
    //}
    for(i=0;i<N;i++){
        for(j=0;j<D;j++){
            scanf("%d",&X[i][j]);
        }
   }
    double d;
    double sum;
    i=0,j=1;
    int count=0;
    int t;
        while(i!=N-1){
        sum = 0;
        //printf("%lf\n",sum);
        for(t=0;t<D;t++){
        //printf("hikizan=%d\n",X[i][t]-X[j][t]);
        sum=sum+pow((X[i][t]-X[j][t]),2);
        //printf("sum=%lf",sum);
        }
        //printf("%lf\n",sum);
        d=sqrt(sum);
        if(ceil(d)==floor(d)){
            count++;
        }
        j++;
        if(j==N){
            i++;
            j=i+1;
        }
        }
    printf("%d\n",count);   
    //for(i=0;i<N;i++){
     //   free(X[i]);
   // }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

#define maxn 110
int s[maxn];
bool f[maxn * maxn];
int main()
{
	int n, sum = 0; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &s[i]), sum += s[i];
	f[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = sum; j >= s[i]; --j)
			f[j] |= f[j - s[i]];
	}
	int ans = 0;
	for (int i = 0; i <= sum; ++i) if (i % 10 && f[i]) ans = i;
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(ll i = 1; i*i<=m; ++i) {
        if(m%i!=0) continue;
        ll x = m/i;
        if(i*n <= m) ans = max(ans, i);
        if(x*n <= m) ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}   

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,dp[N],sum[26];
char str[N];
int mn[1<<26];

inline void ins(int x,int y){
	if(!mn[x]) mn[x]=y; else gmin(mn[x],y);
}
inline int calc(int x){
	if(!mn[x]) return inf;
	return mn[x];
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%s",str+1);n=strlen(str+1);
	ins(0,1);
	for(int i=1;i<=n;i++){
		int st=0;
		for(int j=0;j<26;j++){
			sum[j]+=(str[i]==j+'a');
			st|=(sum[j]&1)<<j;
		}
		dp[i]=calc(st)+1;
		for(int j=0;j<26;j++)
			if(sum[j]) gmin(dp[i],calc(st^(1<<j))+1);
		ins(st,dp[i]);
	}
	printf("%d\n",dp[n]-1);
	return 0;
}

Measured memory_bytes: 263040
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else shuffle(i-1, cnt+readInt)

    if(w=="-") return else { println(shuffle(readInt, 0));exec(readLine) }
  }
  exec(readLine)
}

Measured memory_bytes: 43844
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
int N;
string s[Max];

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(s, N);
    rep(i, N) {
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s+N);
    // rep(i, N) {
    //     output(s[i]);
    // }

    ll ans = 0;
    ll cnt = 1;
    repd(i, 1, N) {
        if (s[i] == s[i-1]) {
            cnt++;
        } else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    ans += cnt * (cnt - 1) / 2;

    output(ans);

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int ans=0;
  if(N / 100 == 7){
    ans++;
  }else if(N / 10 % 10 == 7){
    ans++;
  }else if(N % 10 == 7){
    ans++;
  }

  if(ans > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long ans = 0;
		int x = 39;
		List<Long> list = new ArrayList<>();
		for ( ; x >= 0; x--) {
			list.clear();
			for (int i = 0; i < n; i++) {
				long sum = 0;
				for (int j = i; j < n; j++) {
					sum += a[j];
					if ((sum >> x & 1) == 1) {
						list.add(sum);
					}
				}
			}
			if (list.size() >= k) {
				ans += (1L << x);
				break;
			}
		}
		x--;
		for ( ; x >= 0; x--) {
			List<Long> list2 = new ArrayList<>();
			for (long e : list) {
				if ((e >> x & 1) == 1) {
					list2.add(e);
				}
			}
			if (list2.size() >= k) {
				ans += (1L << x);
				list = list2;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 41300
n = int(input())
ABCs = [list(map(int, input().split())) for i in range(n)]

last = -1

dp = [[None]*3 for i in range(n)]
dp[0] = [0,0,0]
# print(dp)

#dp[i][j] := i日目に行動jを選択したときの幸福度の総和の最大値

for i in range(n+1):
    if i == 0:
        continue
    if i == 1:
        dp[i-1][0] = ABCs[i-1][0]
        dp[i-1][1] = ABCs[i-1][1]
        dp[i-1][2] = ABCs[i-1][2]
        continue
    for j in range(3):

        actions = ABCs[i-1]

        # j以外の選択の中で，最大の幸福をもっているやつ + j
    
        dp[i-1][j] = max([dp[i-2][k] for k in range(3) if k != j]) + ABCs[i-1][j]

print(max(dp[n-1]))

Measured memory_bytes: 47364
// 2020-07-26 08:01:20
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

using T = tuple<int, int, int>; // x+y, x, y
const int INF = 1e9;
int n;
vector<T> p[4]; // D, L, U, R
void rotate() {
  rep(d, 4) {
    for(auto& a : p[d]) {
      int xy, x, y;
      tie(xy, x, y) = a;
      int nx = -y+200000;
      int ny = x;
      a = T(nx+ny, nx, ny);
    }
  }
}
void answer() {
  cin >> n;
  rep(i, n) {
    int x, y;
    char u;
    cin >> x >> y >> u;
    if(u == 'D') p[0].emplace_back(T(x+y, x, y));
    if(u == 'L') p[1].emplace_back(T(x+y, x, y));
    if(u == 'U') p[2].emplace_back(T(x+y, x, y));
    if(u == 'R') p[3].emplace_back(T(x+y, x, y));
  }
  int ans = INF;
  rep(k, 4) {
    int i = k, j = (i+1) % 4;
    for(int d : {i, j}) {
      sort(ALL(p[d]));
    }
    for(const auto& a : p[i]) {
      int xy, x, y;
      tie(xy, x, y) = a;
      auto itr = upper_bound(ALL(p[j]), T(xy, x, INF));
      if(itr == p[j].end()) break;
      int bxy, bx, by;
      tie(bxy, bx, by) = *itr;
      bool ok = x < bx && by < y && (bx-x) == (y-by);
      if(ok) chmin(ans, (y - by) * 10);
    }
    rotate();
  }
  rep(k, 2) {
    int i = k, j = i + 2;
    swap(i, j);
    for(int d : {i, j}) {
      for(auto& a : p[d]) a = T(0, get<1>(a), get<2>(a));
      sort(ALL(p[d]));
    }
    for(const auto& a : p[i]) {
      int xy, x, y;
      tie(xy, x, y) = a;
      auto itr = upper_bound(ALL(p[j]), T(0, x, y));
      if(itr == p[j].end()) break;
      int bxy, bx, by;
      tie(bxy, bx, by) = *itr;
      bool ok = x == bx && y < by;
      if(ok) chmin(ans, (by - y) * 5);
    }
    rotate();
  }
  if(ans == INF) cout << "SAFE" << '\n';
  else cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 7012
#include <stdio.h>

int main(void){
  int n,max,min;
  int i,times;
  double sum=0;

  scanf("%d",&times);
  for(i=0;i<times;i++){
    scanf("%d",&n);
    if(i==0){
      max=n;
      min=n;
    }
    if(n>max) max=n;
    if(n<min) min=n;
    sum+=n;
  }

  printf("%d %d %.0f\n",min,max,sum);

  return 0;
}
    

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
	int ans=0;
  	int cur=0;
  	string t="";
  	string prev="";
  	while(cur<s.size()){
    	t+=s[cur];
		cur++;
    	if (t!=prev){
			prev=t;
          	t="";
          	ans++;
        }
    }
  	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int A, B, C;
            cin >> A >> B >> C;
                if(A==5&&B==7&&C==5){
                    cout << "YES" << endl;
                }else if(A==5&&B==5&&C==7){
                    cout << "YES" << endl;
                }else if(A==7&&B==5&&C==5){
                    cout << "YES" << endl;
                }else{
                    cout << "NO" << endl;
                }
    return 0;}

Measured memory_bytes: 256
#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;
ll const inf = 2e5+1;

void solve()
{   

    ll a,b,c; cin >> a >> b >> c;

    map<ll,ll> cnt;
    cnt[a]++, cnt[b]++, cnt[c]++;

    if((cnt[5]==2&&cnt[7]==1) )
        cout << "YES\n";
    else
        cout << "NO\n";
}

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


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

Measured memory_bytes: 3640
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        String S = scan.next();

        boolean flag = false;
        for(int i=0;i<S.length();i++){
            char c = S.charAt(i);
            if(i%2 == 0){
                if(c=='L'){
                    flag = true;
                }
            }else{
                if(c=='R'){
                    flag = true;
                }
            }
        }

        if(flag){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 10000000

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]+n<='Z'){
            cout << char(s[i]+n);
        }else{
            cout << char(s[i]+n-26);
        }
    }
    cout << endl;
}

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

sosuu=[11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471,1481,1511,1531,1571,1601,1621,1721,1741,1801,1811,1831,1861,1871,1901,1931,1951,2011,2081,2111,2131,2141,2161,2221,2251,2281,2311,2341,2351,2371,2381,2411,2441,2521,2531,2551,2591,2621,2671,2711,2731,2741,2791,2801,2851,2861,2971,3001,3011,3041,3061,3121,3181,3191,3221,3251,3271,3301,3331,3361,3371,3391,3461,3491,3511,3541,3571,3581,3631,3671,3691,3701,3761,3821,3851,3881,3911,3931,4001,4021,4051,4091,4111,4201,4211,4231,4241,4261,4271,4391,4421,4441,4451,4481,4561,4591,4621,4651,4691,4721,4751,4801,4831,4861,4871,4931,4951,5011,5021,5051,5081,5101,5171,5231,5261,5281,5351,5381,5431,5441,5471,5501,5521,5531,5581,5591,5641,5651,5701,5711,5741,5791,5801,5821,5851,5861,5881,5981,6011,6091,6101,6121,6131,6151,6211,6221,6271,6301,6311,6361,6421,6451,6481,6491,6521,6551,6571,6581,6661,6691,6701,6761,6781,6791,6841,6871,6911,6961,6971,6991,7001,7121,7151,7211,7321,7331,7351,7411,7451,7481,7541,7561,7591]

n_int = map(str, sosuu[:n])
answer = " ".join(n_int)
print(answer)

#print(sosuu[:n])

Measured memory_bytes: 3192
#include <iostream>
// #include <vector>

using namespace std;

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

  long sum = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    sum += a - 1;
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
X = [[0 for _ in range(3)] for _ in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[n]:
                X[i][j] = 1
tate = any([all([X[i][j] for j in range(3)]) for i in range(3)])
yoko = any([all([X[i][j] for i in range(3)]) for j in range(3)])
nana = all([X[i][i] for i in range(3)]) or all([X[i][2 - i] for i in range(3)])
if tate or yoko or nana:
    print('Yes')
else:
    print('No')

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

int main(){
    int x; cin >> x;
    int ans =0;
    while(x>=500){
        ans += 1000;
        x -= 500;
    }
    while(x >=5){
        ans += 5;
        x-=5;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <algorithm> 
#include <cmath> 
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int N=s.size();
    int ans =999;
    for(int i=0;i<=N-3;++i){
        int num=(s[i]-'0')*100+(s[i+1]-'0')*10 +s[i+2]-'0';
        ans=min(ans,abs(num-753));

    }
    cout<<ans<<endl;
}

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

int main(){
    string A;
    string B;
    cin>>A>>B;
    int n=A.size();
    int m=B.size();
    int dp[n+1][m+1];
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else{
                if(A[i-1]==B[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
    
    string out="";
    int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
     
      if (A[i-1] == B[j-1]) 
      { 
          out=A[i-1]+out;
          i--; j--;   
      } 
  

      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
    
    cout<<out<<endl;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
 
int main() {
	int m, f, r;
	cin >> m >> f >> r; 
	while (m != -1 || f != -1){
		int k = m + f ;
		if (m == -1 || f == -1)
			cout << "F" << endl;
		else if (k >= 80) 
			cout << "A" << endl;
		else if (k >= 65)
			cout << "B" << endl;
		else if (k >= 50 || r >= 50)
			cout << "C" << endl;
		else if (k >= 30)
			cout << "D" << endl;
		else if (k < 30)
			cout << "F" << endl;
		cin >> m >> f >> r;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>

void print(int S);

int main()
{
	int S;
	std::cin >> S;

	print(S);
	
	return 0;
}

#include <cstdio>

void print(int S)
{
	int h, m, s;

	s = S % 60;
	m = (S / 60) % 60;
	h = (S / 60) / 60;

	std::printf("%d:%d:%d\n", h, m, s);
}

Measured memory_bytes: 1144
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = (int) 1e5 + 5;

const int MOD = (int)1e9 + 7;

int n, h[MAXN], sorted[MAXN];

int qpow(int a, int x) {
    int res = 1;
    for (; x > 0; x >>= 1) {
        if (x & 1)
            res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
    }
    return res;
}

bool added[MAXN];
int R_L[MAXN], L_R[MAXN];

int dp[MAXN][2][2][2];
int last_h[MAXN];

void merge(int dp_l[2][2][2], int dp_r[2][2][2], int res[2][2][2]) {
    int tmp[2][2][2];
    
    memset(tmp, 0, sizeof tmp);
    
    for (int l = 0; l < 2; ++l)
    for (int r = 0; r < 2; ++r) {
        for (int ll = 0; ll < 2; ++ll)
        for (int rr = 0; rr < 2; ++rr)
        for (int sl = 0; sl < 2; ++sl)
        for (int sr = 0; sr < 2; ++sr) {
            int t = sl | sr | (ll == rr);
            tmp[l][r][t] = (tmp[l][r][t] + 1LL * dp_l[l][ll][sl] * dp_r[rr][r][sr]) % MOD;
        }
    }
    
    memcpy(res, tmp, sizeof tmp);
}

void calc(int L, int h_now) {
    if (last_h[L] == h_now) {
        return;
    }
    
    int tmp[2][2][2];
    int t = (last_h[L] - h_now) & 1;

    for (int l = 0; l < 2; ++l)
    for (int r = 0; r < 2; ++r) {
        tmp[l][r][1] = dp[L][l ^ t][r ^ t][1];
        tmp[l][r][0] = 1LL * (dp[L][l][r][0] + dp[L][l ^ 1][r ^ 1][0]) * qpow(2, last_h[L] - h_now - 1) % MOD;
    }

    memcpy(dp[L], tmp, sizeof tmp);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", h + i);
        sorted[i] = i;
    }
    
    std::sort(sorted + 1, sorted + n + 1, [&] (int a, int b) {
        return h[a] > h[b];
    });

    for (int i = 1; i <= n; ++i) {
        int j = sorted[i];

        int tmp[2][2][2];
        int L = j, R = j;

        memset(tmp, 0, sizeof tmp);
        tmp[0][0][0] = tmp[1][1][0] = 1;

        if (R_L[j - 1]) {
            int l = R_L[j - 1], r = j - 1;
            L_R[l] = R_L[r] = 0;
            calc(l, h[j]);
            merge(dp[l], tmp, tmp);
            L = l;
        }

        if (L_R[j + 1]) {
            int l = j + 1, r = L_R[j + 1];
            L_R[l] = R_L[r] = 0;
            calc(l, h[j]);
            merge(tmp, dp[l], tmp);
            R = r;
        }

        added[j] = true;
        memcpy(dp[L], tmp, sizeof tmp);
        L_R[L] = R;
        R_L[R] = L;
        last_h[L] = h[j];
    }

    if (h[sorted[n]] > 1) {
        int t = (h[sorted[n]] - 1) & 1;
        int tmp[2][2][2];

        for (int l = 0; l < 2; ++l)
        for (int r = 0; r < 2; ++r) {
            tmp[l][r][1] = dp[1][l ^ t][r ^ t][1];
            tmp[l][r][0] = 1LL * (dp[1][l][r][0] + dp[1][l ^ 1][r ^ 1][0]) * qpow(2, h[sorted[n]] - 1 - 1) % MOD;
        }
        
        memcpy(dp[1], tmp, sizeof tmp);
    }

    int ans = 0;
    for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
    for (int k = 0; k < 2; ++k) {
        ans = (ans + dp[1][i][j][k]) % MOD;
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 2176
//  RAKSHIT KADAM
 #include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!

 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 200006
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define endl "\n"
 #define x first
 #define y second
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 1000000000000000005
 #define vi vector<ll>
 #define PI 3.14159265

using namespace std;
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}

//ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll a[MAX];
void solve()
{
    ll k;cin>>k;
    ll n;cin>>n;
    forci(i,n)cin>>a[i];
    ll minn=INF;
    a[n]=a[0];
    for(ll i=1;i<n;i++)
    {
        minn=min(minn,k-a[i]+a[i-1]);
    }
    cout<<min(minn,a[n-1]-a[0])<<endl;
}
signed main()
{
    Need_for_speed(activated);
//       satisfy
//       {
//           solve();
//       }
//
  solve();
//
    
    return 0;}




Measured memory_bytes: 1792