akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,};
const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,};
const int dz[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,};

const double EPS = 1e-9;

int main(){
    while(true){
        int n,m,p;
        cin >> n >> m >> p;
        if(n == 0) break;
        vector<vector<vector<char> > > F(n,vector<vector<char> >(n,vector<char>(n,'.')));
        bool win = false;
        bool black = true;
        int turn;
        bool end = false;
        for(int t=0;t<p;t++){
            int x,y;
            cin >> x >> y;
            x--;y--;
            if(end) continue;
            for(int h=0;h<n;h++){
                if(F[x][y][h] == '.'){
                    if(t % 2 == 0){
                        F[x][y][h] = 'b';
                    }else{
                        F[x][y][h] = 'w';
                    }
                    break;
                }
            }

            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    for(int k=0;k<n;k++){
                        for(int l=0;l<26;l++){
                            if(F[i][j][k] == '.') continue;
                            int ddx = dx[l];
                            int ddy = dy[l];
                            int ddz = dz[l];
                            int nx = i;int ny = j;int nz = k;
                            bool ok = true;
                            for(int o=0;o<m;o++){
                                if(not (0 <= nx and nx < n and 0 <= ny and ny < n and 0 <= nz and nz < n and F[nx][ny][nz] == F[i][j][k])){
                                    ok = false;
                                }
                                nx += ddx;
                                ny += ddy;
                                nz += ddz;
                            }
                            if(ok) {
                                turn = t+1;
                                win = true;
                                black = turn % 2;
                                end = true;
                            }
                        }
                    }
                }
            }
        }
        if(win){
            if(black){
                cout << "Black";
            }else{
                cout << "White";
            }
            cout << " " << turn << endl;
        }else{
            cout << "Draw" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int sum = accumulate(s.begin(), s.end(), 0) - '0' * s.size();
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 998244353;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long n;
    cin >> n;
    VI as;
    REP(i,3*n) {
        long a;
        cin >> a;
        as.push_back(a);
    }
    sort(as.begin(), as.end());
    
    long ans = 0;
    for (long i = n; i < 3 * n; i += 2) {
        ans += as[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        cout << 0;
    }
    else
    {
        cout << a-b;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
double a, b, x;
double calc (double angle) {
  angle = (angle * M_PI) / 180;
  //cerr << angle << endl;
  if (a * sin(angle) > b * cos(angle)) {
    //cerr << 'a' << endl;
    //cerr << tan(M_PI / 2 - angle) << endl;
    double k = b * tan(M_PI / 2 - angle);
    //cerr << k << endl << endl;
    double area = k * b / 2;
    return area * a;
  } else {
    //cerr << 'b' << endl;
    double k = a * tan(angle);
    //cerr << k << endl << endl;
    return (b + (b - k)) * a * a / 2;
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  cin >> a >> b >> x;
  double lo = 0, hi = 90;
  for (int i = 0; i < 1000; i++) {
    double mid = (lo + hi) / 2;
    if (calc(mid) < x) hi = mid;
    else lo = mid;
  }
  cout << setprecision(20) << fixed << lo << '\n';
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 2; i < 10; ++i) {
        for (int j = 2; j < 10; ++j) {
            if(10 * i + j <= d && i * j <= m) {
                ans ++;
            }
        }
    }
    cout << ans << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int L, R, d;
  scanf("%d %d %d", &L, &R, &d);

  int c = 0;
  for (size_t i = L; i <= R; i++) {
    if (i % d == 0) {
      c++;
    }
  }
  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    fastio
    vector<vector<int>> vec(3, vector<int>(3));
    int rem[3][3];
    memset(rem, 0, sizeof(rem));

    for(int i = 0; i<3; ++i)
    {
        for(int j = 0; j<3; ++j)
        {
            cin>>vec[i][j];
        }
    }

    int n;
    cin>>n;
    for(int i = 0; i<n; ++i)
    {
        int temp;
        cin>>temp;
        for(int k = 0; k<3; ++k)
        {
            for(int l = 0; l<3; ++l)
            {
                if(vec[k][l] == temp)
                {
                    rem[k][l] = 1;
                }
            }
        }
    }

    for(int i = 0; i<3; ++i)
    {
        if(rem[i][0]==1 && rem[i][1] == 1 && rem[i][2]==1)
            {
                cout<<"Yes"<<endl;
                return 0;
            }    

        if(rem[0][i] == 1 && rem[1][i] == 1 && rem[2][i] == 1)
        {
            cout<<"Yes"<<endl;
            return 0;
        }    
    }

    if(rem[0][0] == 1 && rem[1][1] == 1 && rem[2][2] == 1)
    {
        cout<<"Yes"<<endl;
        return 0;
    }

    if(rem[2][0]==1 && rem[1][1]==1 && rem[0][2] == 1)
    {
        cout<<"Yes"<<endl;
        return 0;
    } 

    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

void solve(string s, string t){
    int n = min(s.size(), t.size());
    int res = 0;
    rep(i,n){
        if(s[i] == t[i]){
            res++;
        }
    }
    cout << res << endl;
}

int main() {
    string s, t;
    cin >> s >> t;

    solve(s, t);
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    ll ans=0;
    for(ll bit = 0; bit < (1<<s.size()-1); bit++){
        int fow=0,bac=0;
        for(int i=0;i<s.size()-1;i++){
            if(bit & (1<<i)){
                /*digitsが1だと真*/
                bac=i+1;
                ans+=stoll(s.substr(fow,bac-fow));
                fow=bac;
            }
        }
        ans+=stoll(s.substr(fow,s.size()-fow));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll H, W;
    cin >> H >> W;
    vs s(H);
    queue<vector<ll>> qb;
    vvi bmap(H, vi(W, 0));
    rep(i, H){
        cin >> s[i];
        rep(j, W){
            if(s[i][j] == '#'){
                bmap[i][j] = 1;
            }
        }
    }
    rep(i, H){
        rep(j, W){
            if(bmap[i][j]){
                qb.push({1, i, j});
                int dx[4] = {1, 0, -1, 0};
                int dy[4] = {0, 1, 0, -1};
                int depth = 1;
                while (!qb.empty()){
                    vll qf = qb.front();
                    qb.pop();
                    depth = qf[0];
                    bmap[qf[1]][qf[2]] = 0;
                    rep (k, 4){
                        if (0 <= qf[1] + dx[k] && qf[1] + dx[k] < H && 0 <= qf[2] + dy[k] && qf[2] + dy[k] < W){
                            if (bmap[qf[1] + dx[k]][qf[2] + dy[k]]){
                                bmap[qf[1] + dx[k]][qf[2] + dy[k]] = 0;
                                qb.push({qf[0] + 1, qf[1] + dx[k], qf[2] + dy[k]});
                            }
                        }
                    }
                }
                if(depth == 1){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(void) {
    int N;
    string S;
    int x = 0;
    int max = 0;

    cin >> N >> S;

    for(int i;i<S.size();i++) {
        if(S[i] == 'I') {
            x++;
            if(max < x) {
                max = x;
            }
        } else {
            x--;
        }
    }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N, Y;
  cin >> N >> Y;

  for (int i = 0; i <= 2000; ++i) {
    for (int j = 0; j <= 2000; ++j) {
      const int k = N - (i + j);
      if (k < 0) break;
      if (10000LL * i + 5000LL * j + 1000LL * k == Y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }

  printf("%d %d %d\n", -1, -1, -1);

  return 0;
}



Measured memory_bytes: 256
S = 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)
elif S == 'SAT':
    print(1)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        long A = Long.parseLong(s[0]);
        long B = Long.parseLong(s[1]);
        long C = Long.parseLong(s[2]);
        long D = Long.parseLong(s[3]);
        System.out.println((B - A + 1) - divider(A, B, C) - divider(A, B, D) + divider(A, B, lcm(C,D)));
    }
    
    public static long divider(long A, long B,long div) {
        long start = 0;
        long end = 0;
        if(A <= div) {
            start = div;
        }else {
            if(A % div == 0) {
                start = A;
            }else {
                start = A + div - A % div;
            }
        }
        
        if(B < div) {
          return 0;
        }else {
            end = B - B % div;
        }
        if(start > end)return 0;
        return (end - start) / div + 1;
    }
    
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
    
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 21076
# -*- coding: utf-8 -*-
n = input()
K = int(input())
l = len(n)
dp = [[[0 for _ in range(5)] for _ in range(2)] for _ in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    D = int(n[i])
    for j in range(2):
        for k in range(4):
            for d in range((9 if j==1 else D)+1):
                J = j==1 or d<D
                if d!=0:
                    dp[i+1][1 if J else 0][k+1] += dp[i][j][k]
                else:
                    dp[i+1][1 if J else 0][k] += dp[i][j][k]

print(dp[l][0][K]+dp[l][1][K])

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

#define ll long long

using namespace std;

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

    vector<ll> a(N), f(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<>());

    ll left = -1, right = 1e13;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        ll num = 0;//修行回数
        for (int i = 0; i < N; i++) {
            num += max(0LL, a[i] - mid / f[i]);
        }
        (num <= K) ? (right = mid) : (left = mid);
    }

    cout << right << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl; 
using namespace std; 

//int _; 

int h1,m1,h2,m2,k;

int main()
{
	//for(scanf("%d",&_);_;_--)
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	cout << (h2-h1)*60+m2-m1-k << endl;
	return 0;
}

Measured memory_bytes: 3764
//
//  main.cpp
//  ABC169B2
//
//  Created by TakahiroUryu on 2020/06/07.
//  Copyright © 2020 TakahiroUryu. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    long long mx = 1000000000000000000;
    int N;
    cin >> N;
    vector<long long>A(N);
    long long ans=1;
    // 整数をN個、読み込む
    // ０が含まれていたら、０を出力する
    for (int  i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if (A.at(i)==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    // それぞれを乗算する
    // mxより大きくなったら、−１を出力する
    for (int i=0; i<N; i++) {
        if (mx/ans<A.at(i)) {
            cout <<-1<<endl;
            return 0;
        }
        ans *= A.at(i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll a,b,n,t;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> a >> b >> n;
	if(b <= n){
		t = b - 1;
	}else{
		t = n;
	}
	ll res = (a * t)/b;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3124
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    mt = 0
    for i in range(n):
        zs = s[i:]
        zln = len(zs)
        zl = [0] * zln
        zi = 1
        zj = 0
        while zi < zln:
            while zi + zj < zln and zs[zj] == zs[zi+zj]:
                zj += 1
            zl[zi] = zj
            if zj == 0:
                zi += 1
                continue
            zk = 1
            while zi + zk < zln and zk + zl[zk] < zj:
                zl[zi+zk] = zl[zk]
                zk += 1
            zi += zk
            zj -= zk
        for j in range(len(zl)):
            if zl[j] <= j:
                mt = max(mt, zl[j])
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47708
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int N,a,b;
  cin >> N;
  while(N--){
    int n;
    cin >> n; 
    int mou,now;
    int MAX = 0;
    int MIN = 0;
    cin >> now;
    for( int i = 1 ; i < n ; i++ ){
      cin >> mou;
      a = mou - now;
      if( a > 0 ){
	MAX = max( a , MAX );
      }else {
	MIN = max( -a , MIN );  
      }
      now = mou;
    }
    cout << MAX << " " << MIN << endl;
  }
  return 0;
}

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

int main() {
    string s; cin >> s;
    int K; cin >> K;
    set<string> ans;
    int ss = s.size();
    rep(i, ss){
        int c = min(ss-i, K);
        for (int j = 1; j <= c; j++){
            string a = s.substr(i, j);
            ans.insert(a);
        }
    }
    
    int cnt = 0;
    for(auto x : ans){
        if(cnt == K-1){
            cout << x << endl;
            break;
        }
        cnt++;
    }

    return 0;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt();
      int debt = 100000;
      for (int i = 0; i < n; i++) {
        debt *= 105;
        if (debt % 100000 != 0) {    
          debt = debt / 100000;
          debt = debt * 1000 + 1000;
        } else {
          debt /= 100;
        }
      }
      
      out.println(debt);
      
//      End solve()
    }
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 24140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  string s[H];
  for(int i=0;i<H;i++){
    cin>>s[i];
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Jan 24 14:25:11 2019
//
package main

import "fmt"

func scanSlice(slice []int) {
	for i := range slice {
		fmt.Scan(&slice[i])
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func max(args ...int) int {
	m := 0
	for _, a := range args {
		if m < a {
			m = a
		}
	}
	return m
}

func min(args ...int) int {
	m := 1 << 60
	for _, a := range args {
		if a < m {
			m = a
		}
	}

	return m
}

func equlibium(slice []int) (ps []int, qs []int) {
	index := 1
	for k := 2; k <= len(slice)-2; k++ {
		p := slice[index-1]
		q := slice[k-1] - slice[index-1]
		diff := abs(p - q)
		for index+1 < k {
			a := slice[index]
			b := slice[k-1] - slice[index]
			if abs(a-b) > diff {
				break
			}
			diff = abs(a - b)
			index++
			p = slice[index-1]
			q = slice[k-1] - slice[index-1]
		}
		ps = append(ps, p)
		qs = append(qs, q)
	}

	return ps, qs
}

func main() {
	var N int
	fmt.Scan(&N)

	slice := make([]int, N)
	scanSlice(slice)

	acc := make([]int, N)
	for i := range slice {
		if i == 0 {
			acc[i] = slice[0]
		} else {
			acc[i] = slice[i] + acc[i-1]
		}
	}
	ps, qs := equlibium(acc)

	revAcc := make([]int, N)
	for i := range revAcc {
		if i == 0 {
			revAcc[i] = slice[len(slice)-1]
		} else {
			revAcc[i] = slice[len(slice)-1-i] + revAcc[i-1]
		}
	}
	rs, ss := equlibium(revAcc)

	ans := 1 << 60
	for i := range ps {
		p, q, r, s := ps[i], qs[i], rs[len(ps)-1-i], ss[len(ps)-1-i]
		diff := max(p, q, r, s) - min(p, q, r, s)
		if diff < ans {
			ans = diff
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 21504
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;
struct aa {
	string st;
	int from;
	int to;
};
bool operator>(const aa&l, const aa&r) {
	return l.from> r.from;
}
bool operator==(const aa&l, const aa&r) {
	return l.from== r.from;
}
class Compare {
public:
	//aaが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.from> r.from;
	}
};
bool comp_func(const aa&l, const aa&r) {
	return l.from < r.from;
}
int main() {
	while (1) {
		int N, Q; cin >> N >> Q;
		if (!N)break;
		vector<aa>names;
		for (int i = 0; i < N; ++i) {
			string st; cin >> st;
			int eby, year; cin >> eby >> year;
			names.push_back(aa{ st,year - eby + 1,year });

		}
		sort(names.begin(), names.end(), [](const aa&l, const aa&r) {return l.from < r.from; });
		for (int i = 0; i < Q; ++i) {
			int y; cin >> y;

			aa aaa{ "",y,y };
			auto it = upper_bound(names.begin(), names.end(), aaa, comp_func);
			if (it == names.begin())cout << "Unknown" << endl;
			else {
				if (prev(it)->to >= y) {
					cout << prev(it)->st << " " << y - prev(it)->from + 1 << endl;
				}
				else {
					cout << "Unknown" << endl;
				}
			}
		}
	}

	return 0;
}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n;
    cin >> n;
    for (int i = 1; i < 1000; i++) {
        if (1000 * i >= n) {
            cout << 1000 * i - n << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3656
import random

d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = [random.choice(range(26)) for i in range(d)]
score = 0

for _ in range(10**5):
    p = random.choice(range(d))
    q = random.choice(range(26))
    memo = T[p]
    T[p] = q
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    tmp = 0
    for i in range(d):
        tmp += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        tmp -= C[j] * (dd - X[j])
    if tmp > score:
        score = tmp
    else:
        T[p] = memo

for t in T:
    print(t + 1)


Measured memory_bytes: 84552
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
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; }
 
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; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char G[505][505];
int cost[505][505];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  int n=s.size(), m=t.size();
  
  if(n<m){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  
  string ans="";
  rep(i,n-m+1){
    bool ok=true;
    rep(j,m){
      if(s[i+j]!='?' && s[i+j]!=t[j]){
        ok=false;
        break;
      }
    }
    if(ok){
      ans=s;
      rep(j,m) ans[i+j]=t[j];
    }
  }
  
  if(ans==""){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }
  
  rep(i,n) if(ans[i]=='?') ans[i]='a';
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# your code goes here
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
ans = 0
red = sorted(red, key = lambda x:  x[1]*(-1))
blue = sorted(blue)

for b in blue:
	for r in red:
		if r[0] < b[0] and r[1] < b[1]:
			ans += 1
			red.remove(r)
			break
print(ans)

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

const int mo=924844033;
int n,k,f[2010][2010][2],g[2010],fac[2010],ifac[2010],ans;

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

void work()
{
	scanf("%d %d",&n,&k);
	fac[0]=1;
	for (int i=1; i<=n; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	f[0][0][0]=1;
	for (int i=1; i<=n/k+1; i++)
		for (int j=0; j<=(i+1)/2; j++)
			{
				f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mo;
				if (j)  f[i][j][1]=f[i-1][j-1][0];
			}
	g[0]=1;
	for (int i=1,len,s=0; i<=n&&i<=k; i++)
		{
			len=(n-i)/k;
			for (int k=s; k>=0; k--)
				for (int j=1; j<=(len+1)/2; j++)
					g[j+k]=(g[j+k]+1LL*g[k]*(f[len][j][0]+f[len][j][1]))%mo;
			s+=(len+1)/2;
			for (int k=s; k>=0; k--)
				for (int j=1; j<=(len+1)/2; j++)
					g[j+k]=(g[j+k]+1LL*g[k]*(f[len][j][0]+f[len][j][1]))%mo;
			s+=(len+1)/2;
		}
	for (int i=0; i<=n; i++)
		if (i&1)  ans=(ans+mo-1LL*g[i]*fac[n-i]%mo)%mo;
		else  ans=(ans+1LL*g[i]*fac[n-i])%mo;
	printf("%d",ans);
}

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


Measured memory_bytes: 30080
n = gets.chomp.to_i
s = gets.chomp.split("")
east = [0]
west = [0]

s.each_with_index do |e, i|
    if e === "W" then
        west << west[i] + 1
        east << east[i]
    else
        west << west[i]
        east << east[i] + 1
    end
end

ans = []

1.upto(n) do |i|
    ans << east[-1]-east[i] + west[i-1]
end

print ans.min

Measured memory_bytes: 34620
#include<stdio.h>
int main() {

	char i[4];

	scanf("%s", i);

	if (i[0] == 'R' && i[1] == 'R' && i[2] == 'R')
		printf("3");
	else if ((i[0] == 'R' && i[1] == 'R') || (i[1] == 'R' && i[2] == 'R'))
		printf("2");
	else if (i[0] == 'S' && i[1] == 'S' && i[2] == 'S')
		printf("0");
	else
		printf("1");

	return 0;
}

Measured memory_bytes: 1948
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{

    
    int x;
    
    for(int i = 0; i < 5; i++)
    {
        cin >> x;
        if(x == 0)
        {
            cout << i+1;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int L = array[0];
            int R = array[1];

            if (L + 2019 <= R) {
                System.out.println(0);
                System.exit(0);
            }

            L %= 2019;
            R %= 2019;
            if (R <= L) {
                System.out.println(0);
                System.exit(0);
            }

            int mod = 2019;
            for (int i = L; i <= R; i++) {
                for (int j = i + 1; j <= R; j++) {
                    int m = (i * j) % 2019;
                    if (m < mod) {
                        mod = m;
                    }
                }
            }

            System.out.println(mod);
        }
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define delete _delete

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 1e6;
const ll mod = 1e9 + 7;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl;exit(0);}

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

    ll n;
    cin >> n;

    vector <ll> a(n + 1);

    multiset <ll> s;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
        s.insert(a[i]);
    }

    for(int i = 1; i <= n; i++){
        s.erase(s.find(a[i]));
        cout << *--s.end() << "\n";
        s.insert(a[i]);
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;


int n;
int gl[120000];
int gr[120000];
int a[120000];
int mx[120000];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> gl[i];
	for (int i = 0; i < n; ++i)
		cin >> gr[i];
	int pr = 0;
	for (int i = 0; i < n; ++i) {
		mx[i] = gl[i];
		if (gl[i] > pr) {
			pr = gl[i];
			a[i] = gl[i];
		}
	}
	pr = 0;
	for (int i = n - 1; i >= 0; --i) {
		mx[i] = min(mx[i], gr[i]);
		if (gr[i] > pr) {
			pr = gr[i];
			if (a[i] != 0) {
				if (a[i] != gr[i]) {
					cout << 0 << "\n";
					return 0;
				}
			}
			a[i] = gr[i];
		}
	}
	for (int i = 0; i < n; ++i)
		if (a[i] > mx[i]) {
			cout << 0 << "\n";
			return 0;
		}
	ll ans = 1;
	for (int i = 0; i < n; ++i) {
		if (a[i] == 0)
			ans = (ans * mx[i]) % (ll)(1e9 + 7);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using namespace std;
const long MOD=1e9+7;
template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    long s;
    cin >> s;
    map<long,long> a;
    a[s]++;
    long n=s;
    long m=1;
    while(1){
        m++;
        if(n%2==0){
            n=n/2;
            a[n]++;
            if(a[n]==2){
                cout << m;
                return 0;
            }
        }else{
            n=3*n+1;
            a[n]++;
            if(a[n]==2){
                cout << m;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()

	fmt.Printf("%d\n", (n-1)*(m-1))

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        h: usize, w: usize,
        grid_a: [[usize; w]; h],
        grid_b: [[usize; w]; h],
    };

    let max_abs = 80_usize * 160;
    let mut used = vec![vec![vec![false; max_abs * 2 + 1]; w]; h];
    used[0][0][max_abs] = true;
    let mut res = std::isize::MAX;
    for i in 0..h {
        for j in 0..w {
            let a = grid_a[i][j];
            let b = grid_b[i][j];
            // ex: max_abs: 2
            // -2, -1, 0, 1, 2
            for k in 0..max_abs * 2 + 1 {
                if used[i][j][k] {
                    if i == h - 1 && j == w - 1 {
                        let v = ((k + a - b) as isize - max_abs as isize).abs();
                        if v < res {
                            res = v;
                        }
                        let v = ((k + b - a) as isize - max_abs as isize).abs();
                        if v < res {
                            res = v;
                        }
                    }
                    if i + 1 < h {
                        let new_i = i + 1;
                        let new_j = j;
                        used[new_i][new_j][k + a - b] = true;
                        used[new_i][new_j][k + b - a] = true;
                    }
                    if j + 1 < w {
                        let new_i = i;
                        let new_j = j + 1;
                        used[new_i][new_j][k + a - b] = true;
                        used[new_i][new_j][k + b - a] = true;
                    }
                }
            }
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int calc(int a) {
  if (a > 3) {
    return 0;
  } else if (a == 3) {
    return 100000;
  } else if (a == 2) {
    return 200000;
  } else {
    return 300000;
  }
}
int main() {
  int x, y;
  cin>>x>>y;
  int ans = calc(x) + calc(y);
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# DFS
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = 10 ** 9 + 100
ans = INF
def dfs(i, S, cost, C_list, A_list, N, M, X):
    global ans
    # print(i, buy, cost, S)
    if i == N:
        ok = True
        for j in range(M):
            if S[j] < X:
                ok = False
                break
        if ok:ans = min(ans, cost)
        return
    dfs(i+1, S, cost, C_list, A_list, N, M, X)
    for j in range(M):
        S[j] += A_list[i][j]
    cost += C_list[i]
    dfs(i+1, S, cost, C_list, A_list, N, M, X)
    for j in range(M):
        S[j] -= A_list[i][j]
    cost -= C_list[i]
def main():
    global INF, ans
    N, M, X = map(int, input().split())
    C_list = []
    A_list = []
    for _ in range(N):
        C_A = list(map(int, input().split()))
        C_list.append(C_A[0])
        A_list.append(C_A[1:])
    S = [0 for _ in range(M)]
    cost = 0
    dfs(0, S, cost, C_list, A_list, N, M, X)
    if ans == INF:ans = -1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9168
#include <iostream>
using namespace std;
int main(void){
  	string s,t;
  	cin>>s>>t;
  	
  	int s_length = (int)s.size();
  	int t_length = (int)t.size();
  	
  	string sub_s,sub_t;
  	int minChange=10000;
  	int change = 0;
  	
  	for(int i=0;i<s_length-t_length+1;i++){
      	change=0;
      	sub_s = s.substr(i,t_length);
      	//cout<<sub_s<<endl;
      	for(int j=0;j<t_length;j++){
          	//cout<<"check : "<<sub_s[j]<<" and "<<t[j]<<endl;
          	if(sub_s[j]!=t[j]){
              	change++;
            }
        }
      	if(change<minChange){
          	minChange=change;
        }
    }
    
  	cout<<minChange<<endl;
  	return 0;
  	
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    ll n,m; cin >> n >> m;
    vvl G(n);
    rep(i,m){
        ll u,v; cin >> u >> v; u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    if(m < n+2){
        puts("No");
        return 0;
    }
    int cnt = 0;
    vl ls;
    rep(i,n){
        if((int)G[i].size() & 1){
            puts("No");
            return 0;
        }
    }
    rep(i,n){
        if((int)G[i].size() >= 6){
            puts("Yes");
            return 0;
        }
        if((int)G[i].size() == 4) cnt++, ls.push_back(i);
    }
    if(cnt >= 3){
        puts("Yes");
    }else{
        vb visit(n,false);
        visit[ls[0]] = true;
        queue<int> q;
        q.push(ls[0]);
        vl a(n,0);
        a[ls[0]] = 1;
        while(!q.empty()){
            ll u = q.front(); q.pop();
            for(auto v : G[u]){
                if(v == ls[1]){
                    a[v] += a[u];
                    continue;
                }
                if(visit[v]) continue;
                a[v] += a[u];
                visit[v] = true;
                q.push(v);
            }
        }
        if(a[ls[1]] == 2){
            puts("Yes");
        }else{
            puts("No");
        }
    }
}

Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll n,ans=0,p=0,q=0;
    cin>>n;
    ll a[n+1],b[n];
    fl(i,0,n+1)cin>>a[i];
    fl(i,0,n)cin>>b[i];
    /*for(ll i=0,j=0;i<n+1,j<n+1;)
    {
        if(a[i]==b[j])
        {
            a[i]=0;
            b[j]=0;
            ans+=a[i];
            i++;j++;
        }
        else if(a[i]>b[j])
        {
            a[i]=a[i]-b[j];
            //b[i]=0;
            ans+=b[j];if(a[i]!=0&&i!=n){i++;j++;}else if(j!=n-1) j++;else break;
            //if(i>j&&j!=n-1)j++;
            //else{
            //i++;j++;}
        }
        else
        {
            ans+=a[i];
            a[i]=0;
            b[j]=b[j]-a[i];
            i++;
        }
    }
    cout<<ans;*/
    /*for(ll i=0,j=0;i<n+1,j<n;)
    {
        if(a[i]>b[j]){if(i>n||j>n-1)break;else {ans+=b[j];i++;j++;}}
        else if(a[i]<b[j])
        {
            if(i>n||j>n-1)break; else {
            ans+=a[i];
            b[j]-=a[i];
            if(abs(i-j)<2)i++;
            else {i++;j++;}
            }
        }
        else 
        {
            if(i>n||j>n-1)break;
            else{
            ans+=a[i];i++;j++;
        }}
        //cout<<ans<<endl;
    }
    cout<<ans;*/
    
    
    for(ll i=0,j=0;i<n+1,j<n;)
    {
        if(a[i]>b[j])
        {
            ans+=b[i];i++;j++;
        }
        else if(a[i]<b[j])
        {
            ans+=a[i];
            b[j]-=a[i];
            p=a[i+1];q=a[i+1]-b[j];
            ///a[i+1]-=b[j];
            if(q>=0){a[i+1]-=b[j];ans+=b[j];}
            else {a[i+1]=0;ans+=p;}
            i++;j++;
        }
        else {ans+=a[i];i++;j++;}
    }
    cout<<ans;
    
    
    
    
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 1792
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<sstream>
#include<fstream>
using namespace std;
int main()
{
  int N,A,B,ans=0;
  cin>>N>>A>>B;
  ans=N-A;
  ans=ans%B;
  cout<<ans;                  
  system("pause");
  return 0;
}

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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    vector<int> L;
    int l;
    for(int i=0;i<N*2;i++){
        cin >> l;
        L.push_back(l);
    }
    
    sort(L.begin(),L.end());
    
    int sum = 0;
    for(int i=0;i<(2*N);i+=2){
        sum += L[i];
    }
    
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 256