akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;

    cin >> n >> a >> b;

    if (a + b - 1 > n)
    {
        cout << -1 << endl;
        return 0;
    }

    if ((ll)a * b < n)
    {
        cout << -1 << endl;
        return 0;
    }

    V res;

    int ma = n;

    for (int i = ma - a + 1; i <= ma; i++)
        res.push_back(i);

    ma = n - a;

    b--;

    for (int i = b; i > 0; i--)
    {
        int t = ma / i;

        for (int j = ma - t + 1; j <= ma; j++)
            res.push_back(j);

        ma -= t;
    }

    REP(i, n)
    cout << res[i] << (i == n - 1 ? "\n" : " ");

    return 0;
}

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void){
    // Your code here!
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,W,dp[111][101010],w[101010],v[101010];
int main()
{
	cin>>n>>W;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=W;j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=0;
				continue;
			}
			if(j>=w[i])
			{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll d,g;cin>>d>>g;
    vll p(d), c(d);
    REP(i,d) cin>>p[i]>>c[i];
    ll ans = inf;
    for(ll i=0; i<(1<<d);i++){
        // cout<<i<<endl;
        ll cnt=0; 
        ll score=0;
        REP(j,d){
            if((i>>j)&1) {
                score += (j+1)*100*p[j];
                score += c[j];
                cnt += p[j];
            }
        }
        if (score < g){
            REPR(j,d){
                // if (i==16) cout<<j<<endl;
                if (!((i>>j)&1)) {
      
                    if (g-score > p[j]*(j+1)*100) cnt += mod;
                    cnt += (g-score) / (100*j+100);
                    if ((g-score) % ((100*j+100))) cnt++;
                    break;
                }
            }
        } 
        // cout<<i<<' '<<score<<' '<<cnt<<endl;
        ans = min(ans, cnt);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	double pos;
	int railWays[10];
	int railLength;
	int i;

	while (~scanf("%d,", railWays)){
		for (i = 1; i < 10; i++){
			scanf("%d,", railWays + i);
		}
		scanf("%d,%d", &a, &b);

		// input phase end

		railLength = 0;
		for (i = 0; i < 10; i++){
			railLength += railWays[i];
		}

		pos = railLength * (1. * a / (a + b));

		for (i = 0; i < 10; i++){
			if (pos <= railWays[i]){
				break;
			}
			pos -= railWays[i];
		}
		printf("%d\n", i + 1);
	}

	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> a(n+1);
	for(int i=1; i<=n; i++) cin >> a[i];
	
	bool balls[n+1];
	for (int i = 0; i <= n; ++i){
		balls[i] = 0;
	}

	int m = 0;
	for(int i=n; i>=1; i--){
		int sum = 0;
		for(int j=i*2; j<=n; j+=i){
			sum += balls[j];
		}
		if(sum % 2 != a[i]) balls[i] = 1;
		m += balls[i];
	}

	cout << m << endl;
	for(int i=1; i<=n; i++)
		if(balls[i]) cout << i << endl;

	return 0;
}

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

int main() {
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int m=n-k;
  if(m>0){
    cout<<k*x+m*y<<endl;
  }
  else{
    cout<<n*x<<endl;
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

class Main {

  public static void main(String[] args) {
    final FastScanner sc = new FastScanner();
    final PrintWriter writer = new PrintWriter(System.out);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int r = sc.nextInt();
    int s = sc.nextInt();
    int p = sc.nextInt();
    String t = sc.next();
    char[] c = t.toCharArray();
    int ans = 0;
    for (int i = 0; i < n; i++) {
      char cc = c[i];
      if (i >= k && cc == c[i - k]) {
        c[i] = 'x';
        continue;
      }
      if (cc == 'r') {
        ans += p;
      } else if (cc == 's') {
        ans += r;
      } else if (cc == 'p') {
        ans += s;
      }
    }
    writer.println(ans);
    writer.flush();
    writer.close();
  }

  // FastScanner --
  static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    public FastScanner() {
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte())
        return buffer[ptr++];
      else
        return -1;
    }

    private boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr]))
        ptr++;
      return hasNextByte();
    }

    public String next() {
      if (!hasNext())
        throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext())
        throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
        throw new NumberFormatException();
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 23632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;

int main() {
  string s, t;
  cin >> s >> t;
  v2c v(26);
  unordered_set<char> a, b;
  vector<pair<char, char>> e;
  bool c = 1;
  rep(i, s.size()){
    bool d = 1;
    rep(j, v[s[i]-'a'].size()){
      if(v[s[i]-'a'][j] == t[i]){
        d = 0;
        break;
      }
    }
    if(d) v[s[i]-'a'].push_back(t[i]);
  }
  rep(i, 26){
    if(v[i].size() > 1){
      c = 0;
      break;
    }
  }
  if(c){
    rep(i, 26) if(v[i].size() > 0) e.push_back({v[i][0], (char)('a'+i)});
    sort(e.begin(), e.end());
    int f = 1;
    rep(i, e.size()){
      if(i < e.size()-1 && e[i].fi == e[i+1].fi) ++f;
      else f = 1;
      if(a.count(e[i].fi)) --f;
      if(f > 1){
        c = 0;
        break;
      }
    }
  }
  if(c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 776
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut hint: Vec<(i64, i64, i64)> = vec![];
    let mut s = 0;

    for _ in 0..n {
        let x: i64 = read();
        let y: i64 = read();
        let h: i64 = read();
        hint.push((x, y, h));
    }

    for i in 0..hint.len() {
        let hi = hint[i];
        if hi.2 != 0 {
            s = i;
            break;
        }
    }

    for x in 0..101 {
        for y in 0..101 {
            let h = hint[s].2 + (hint[s].0 - x).abs() + (hint[s].1 - y).abs();
            let mut f = true;

            for p in &hint {
                let px = p.0;
                let py = p.1;
                let ph = p.2;

                if std::cmp::max(h - (px - x).abs() - (py - y).abs(), 0) != ph {
                    f = false;
                    break;
                }
            }
            if f {
                println!("{} {} {}", x, y, h);
                return;
            }
        }
    }
    //
    // for h in 0..101 {
    //     for w in 0..101 {
    //         let top = hint[s].2 + (w - hint[s].0).abs() + (h - hint[s].1).abs();
    //         if top < 0 {
    //             continue;
    //         }
    //         let mut all = true;
    //         for i in 0..hint.len() {
    //             let hi = hint[i];
    //             let ti = hi.2 + (w - hi.0).abs() + (h - hi.1).abs();
    //             if ti != top {
    //                 all = false;
    //                 break;
    //             }
    //         }
    //
    //         if all {
    //             println!("{} {} {}", w, h, top);
    //             return;
    //         }
    //     }
    // }
}


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

int main() {
  int N;
  cin >> N;
  vector<int>L(N);
  for(int i=0; i<N; i++)cin >> L.at(i);
  
  int L1, L2, L3;
  int count =0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        L1 = max(L.at(i), max(L.at(j), L.at(k)));
        L2 = min(L.at(i), min(L.at(j), L.at(k)));
        L3 = L.at(i)+L.at(j)+L.at(k)-L1-L2;
        if(L1!=L2 && L2!=L3 && L3!= L1){
          if(L1 < L2 + L3){
            count++;
          }
        }
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3632
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
                                                  
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;   
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, m, k;

void solve() {
    scanf("%d %d %d", &n, &m, &k);
    int ans = n + m;

    for (int a = 0; a <= n; ++a) {
        for (int b = 0; b <= m; ++b) {
            int cur = a * m + b * n - a * b;

            if (cur >= k) {
                ans = min(ans, a + b);
            }
        }
    }

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

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    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)){
            while(true){
                int n = sc.nextInt();
                int r = sc.nextInt();
                if(n==0 && r==0){break;}
                int[] oldCards = new int[n];
                int[] newCards = new int[n];
                for(int i=0; i<oldCards.length; i++){
                    oldCards[i] = i+1;
                }
                for(int j=0; j<oldCards.length; j++){
                    newCards[j] = oldCards[j];
                }
                for(int i=0; i<r; i++){
                    int p = sc.nextInt();
                    int c = sc.nextInt();
                    for(int j=0; j<p-1; j++){
                        newCards[n-c-j-1]=oldCards[n-1-j];
                    }
                    for(int j=0; j<c; j++){
                        newCards[n-1-j]=oldCards[n-j-p];
                    }
                    for(int j=0; j<oldCards.length; j++){
                        oldCards[j] = newCards[j];
                    }
                }
                    System.out.println(newCards[n-1]);
            }
            
        }
    }
}


Measured memory_bytes: 37272
#include <stdio.h>

char con[16][16];

int cnt(int x, int y, int a, int b)
{
	if (x > a || y > b || (con[x][y])){
		return (0);
	}
	if (x == a && y == b){
		return (1);
	}
	return (cnt(x + 1, y, a, b) + cnt(x, y + 1, a, b));
}

int main(void)
{
	int a, b, i, j, n, x, y;
	
	while (1){
		scanf("%d %d", &a, &b);
		
		if (!a && !b){
			break;
		}
		
		for (i = 0; i < 16; i++){
			for (j = 0; j < 16; j++){
				con[i][j] = 0;
			}
		}
		
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			
			con[x-1][y-1] = 1;
		}
		
		printf("%d\n", cnt(0, 0, a - 1, b - 1));
	}
	
	return (0);
}

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

int main(){
    string s; cin>>s;
    
    bool flg=true;
    while(flg){
        flg=false;
        int dream = s.rfind("dream");
        int dreamer = s.rfind("dreamer");
        int erase = s.rfind("erase");
        int eraser = s.rfind("eraser");

        if(5 == s.size() - dream){
            s = s.substr(0,dream);
            flg=true;
        }
        if(7 == s.size() - dreamer){
            s = s.substr(0,dreamer);
            flg=true;
        }
        if(5 == s.size() - erase){
            s = s.substr(0,erase);
            flg=true;
        }
        if(6 == s.size() - eraser){
            s = s.substr(0,eraser);
            flg=true;
        }
    }

    if(s.size()==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


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

#define SIZE 40

int main() {
    int n, a, total = 1, naototal = 1;
    cin >> n;
    while(n--) {
        cin >> a;
        total *= 3;
        if(!(a & 1)) {
            naototal *= 2;
        }
    }
    cout << total - naototal << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

const string YES = "Yay!";
const string NO = ":(";

int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll c;
  cin >> c;
  ll d;
  cin >> d;
  ll e;
  cin >> e;
  ll k;
  cin >> k;
  cout << (e-a <= k ? YES : NO) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    
    int pie = 0;
    int apple[200] = {};
    
    for(int i=0;i<N;i++){
        apple[i] = abs(L+i);
        pie += L+i;

    }
        sort(apple,apple+N);

    if(L>0){
    cout << pie-apple[0] << endl;
    }else{
    cout << pie+apple[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    long long c0=0, c1=0;
    
    
    for(int i=1; i<=n; i++){
        c0+=(!(i%k));
    }
    
    if(k%2){
        cout<<c0*c0*c0;
        return 0;
    }
    
    
    if(!(k%2)){
        long long goal=k/2;
        for(int i=1; i<=n; i++){
            c1+=goal==(i%k);
        }
        
    }
    
    cout<<c0*c0*c0+c1*c1*c1;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int h, w; cin >> h >> w;
    vvint c(10, vint(10));
    rep(i, 10) {
        rep(j, 10) cin >> c[i][j];
    }
    vvint a(h, vint(w));
    rep(i, h) {
        rep(j, w) cin >> a[i][j];
    }

    rep(i, 10) {
        rep(j, 10) {
            if(i == j) continue;
            rep(k, 10) {
                if(i == k || j == k) continue;
                chmin(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }
    /*
    rfor(x, c) {
        rfor(t, x) cout << t << " ";
        cout << endl;
    }*/
    int ans = 0;
    rfor(v, a) {
        rfor(x, v) {
            if(x == -1) continue;
            ans += c[x][1];
        }
    }
    print(ans);

    return 0;
}


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

using namespace std;

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


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

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
const int N = 1e5 + 7;

bool doublet(pair<int, int> p) {
	return p.first == p.second;
}

int main() {
	fastIO;
	int n;
	cin >> n;
	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v.push_back({x, y});
	}
	for (int i = 0; i < n-2; i++) {
		if (doublet(v[i]) && doublet(v[i+1]) && doublet(v[i+2])) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#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 ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back



/* do your best */

int main() {
  
  int n; cin >> n;
  string s; cin >> s;
  string t; cin >> t;
  string ans = "";
  for(int i = 0; i < n; i++) ans = ans + s[i] + t[i];
  cout << ans << endl;
  return 0;
}


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

int a;
int b;
int product=1;

int main()
{
    cin>>a>>b;

    for (int i=a; i<=b; i++)
    {
        if (i<0)
        {
            product=product*-1;
        }

        if (i==0)
        {
            cout<<"Zero"<<endl;
            return 0;
        }
    }

    if (product>0)
    {
        cout<<"Positive"<<endl;
    }

    else 
    {
        cout<<"Negative"<<endl;
    }
    
}

Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        long sn = (long)Math.sqrt(n);
        long ans = Long.MAX_VALUE;
        for(long i = 1; i <= sn; i++){
            if(n % i == 0){
                ans = Math.min(ans, Math.max(String.valueOf(i).length(), String.valueOf(n/i).length()));
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int answer = A.at(N-1)-A.at(0);
  cout << answer << endl;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 105;

int N, M;
char grid[MAXN][MAXN];
bool R[MAXN], C[MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    cin >> N >> M;

    for(int a = 0; a < N; a++){
        cin >> grid[a];
        for(int b = 0; b < M; b++){
            if(grid[a][b] == '#'){
                R[a] = C[b] = true;
            }
        }
    }

    for(int a = 0; a < N; a++){
        if(!R[a]){
            continue;
        }
        for(int b = 0; b < M; b++){
            if(C[b]){
                cout << grid[a][b];
            }
        }
        cout << "\n";
    }
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 100100;

struct Dp {
  int loop, stay;
  bool all_black;
};

Dp fdown[MAX];
Dp fup[MAX];

char colors[MAX];
int parent[MAX];
vector<int> E[MAX];

Dp compute(int color, int total_loop, int min_diff, int cnt) {
  if (cnt == 0) {
    if (color) return {0, 0, true};
    else return {0, 0, false};
  } else {
    int nloop_color = color ^ 1 ^ (cnt % 2);
    int loop = total_loop + (nloop_color == 0) + 2*cnt;
    int stay = total_loop + min_diff + (nloop_color == 1) + 2*cnt - 1;
    return {loop, stay, false};
  }
}

int computeRoot(int color, int total_loop, int min_diff, int cnt) {
  if (cnt == 0) return color == 0 ? 1 : 0;

  int nloop_color = color ^ (cnt % 2);
  int loop = total_loop + (nloop_color == 0) + 2*cnt;
  int stay = total_loop + min_diff + (nloop_color == 1) + 2*cnt - 1;
  return min(stay, loop);
}

void dfs_down(int x, int dad) {
  int total_loop = 0;
  int min_diff = 0;
  int cnt = 0;
  for (int y: E[x]) {
    if (y != dad) {
      dfs_down(y, x);

      if (!fdown[y].all_black) {
        cnt++;
        total_loop += fdown[y].loop;
        assert(fdown[y].stay <= fdown[y].loop);
        min_diff = min(min_diff, fdown[y].stay - fdown[y].loop);
      }
    }
  }

  fdown[x] = compute(colors[x], total_loop, min_diff, cnt);
}

int dfs_up(int x, int dad) {
  int min_diff1 = 0, min_diff2 = 0, cnt = 0, total_loop = 0;

  auto update = [&] (Dp f) {
    if (!f.all_black) {
      cnt++;
      total_loop += f.loop;
      int diff = f.stay - f.loop;
      if (diff <= min_diff1) min_diff2 = min_diff1, min_diff1 = diff;
      else if (diff < min_diff2) min_diff2 = diff;
    }
  };

  update(fup[x]);

  for (int y: E[x]) {
    if (y != dad) {
      update(fdown[y]);
    }
  }

  int ret = computeRoot(colors[x], total_loop, min_diff1, cnt);

  for (int y: E[x]) {
    if (y != dad) {
      if (fdown[y].all_black) {
        fup[y] = compute(colors[x], total_loop, min_diff1, cnt);
      } else {
        int diff = fdown[y].stay - fdown[y].loop;
        fup[y] = compute(colors[x], total_loop - fdown[y].loop, min_diff1 == diff ? min_diff2 : min_diff1, cnt - 1);
      }

      ret = min(ret, dfs_up(y, x));
    }
  }

  return ret;
}

int main(void) {
  int N;
  scanf("%d", &N);

  REP(i, N-1) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  scanf("%s", colors);
  REP(i, N) colors[i] = colors[i] == 'B';

  dfs_down(0, -1);

  fup[0] = {0, 0, true};
  int ret = dfs_up(0, -1);
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 17792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
struct SegmentTree {  // For Range Maximum Query
  const T kInvalid;
  vector<T> data;
  int size = -1;

  SegmentTree(int N) : kInvalid(0) {
    size = 1;
    while (size < N) size *= 2;
    data.resize(2 * size - 1, kInvalid);
  }

  void Update(int k, T x) {
    k += size - 1;
    data[k] = x;

    while(k > 0) {
      k = (k - 1) / 2;
      data[k] = max(data[2 * k + 1], data[2 * k + 2]);
    }
  }

  // return value in [a, b]
  T Query(int a, int b) const { return Query(a, b + 1, 0, 0, size); }
  // return value in [a, b) by searching index k node which cover [l, r) region.
  T Query(int a, int b, int k, int l, int r) const {
    // l/r is out of bound.
    if (r <= a || b <= l) {
      return kInvalid;
    }

    // cover full range.
    if (a <= l && r <= b) {
      return data[k];
    }

    T left  = Query(a, b, 2 * k + 1, l, (l + r) /2);
    T right = Query(a, b, 2 * k + 2, (l + r) /2, r);
    return max(left, right);
  }
};

int main() {
  int N; cin >> N;
  vector<LL> h(N), a(N); cin >> h >> a;

  SegmentTree<LL> tree(N + 1);

  for (int i = 0; i < N; ++i) {
    LL vmax = tree.Query(0, h[i]);
    tree.Update(h[i], a[i] + vmax);
  }
  cout << tree.Query(0, N) << endl;
}


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

flag = 1 #一度でも入れ替えをした
cnt = 0
point = 0
while point < N:
    rpoint = point
    for i in range(point,N,1):
        if A[rpoint] > A[i]:
            rpoint = i
    A[point], A[rpoint] = A[rpoint], A[point]
    if point != rpoint:
        cnt += 1
    point += 1

print (' '.join(map(str,A)))
print(cnt)




Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=998244353;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}

ll f[300010],fr[300010];

ll ncr(ll n,ll r){
	if(r==0){
		return 1;
	}else{
		return ((f[n]*fr[r])%MOD*fr[n-r])%MOD;
	}
}

int main(){
	f[0]=1;
	ll n,a,b,k;cin>>n>>a>>b>>k;
	for(ll i=1;i<=n+1;i++){
		f[i]=(f[i-1]*i)%MOD;
	}
	fr[n+1]=mod_pow(f[n+1],MOD-2,MOD);
	for(ll i=n;i>=0;i--){
		fr[i]=(fr[i+1]*(i+1))%MOD;
	}
	ll ans=0;
	for(ll i=0;i<=n;i++){
		if((k-(a*i))%b)continue;
		ll p=(k-(a*i))/b;
		if(p<0||a*i+p*b!=k||p>n)continue;
		(ans+=(ncr(n,i)*ncr(n,p)))%=MOD;
	}
	cout<<ans%MOD<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  c=a;
  sort(c.begin(),c.end());
  int c1=0,c2=0;
  int i=0;
  do{
    if(c==a) c1=i;
    if(c==b) c2=i;
    i++;
  }while(next_permutation(c.begin(),c.end()));
  cout<<abs(c1-c2);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int n;
  string s;
  cin >> n >> s;
  int countW = 0, countE = 0;
  vector<int> tmpE;
  vector<int> tmpW;
  for (int i = 1; i < n; i++)
  {
    if (s[i-1] == 'W')
    {
      countW++;
    }
    tmpW.push_back(countW);
  }
  // for(int i : tmpW) cout << i << endl;
  // cout << "=============-" << endl;

  for (int i = n-2; i >= 0; i--)
  {
    if (s[i+1] == 'E')
    {
      countE++;
    }
    tmpE.push_back(countE);
  }
  // for(int i : tmpE) cout << i << endl;

  int minv = min(tmpW[n-2], tmpE[n-2]);
  // cout << minv << endl;
  for (int i = 0; i < n-2; i++)
  {
    minv = min(minv, tmpE[i] + tmpW[n-3-i]);
    // cout << "=======================================" << endl;
    // cout << minv << endl;
  }
  cout << minv << endl;
  return 0;
}

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

using namespace std;

int main() {
	int n; scanf("%d", &n);

	switch(n%10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			printf("hon\n");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			printf("pon\n");
			break;
		case 3:
			printf("bon\n");
	}

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    for (int check : A) {
        if (check % 2 == 0 && check % 3 != 0 && check % 5 != 0) {
            cout << "DENIED";
            return 0;
        }
    }

    cout << "APPROVED";

    return 0;
}


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

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

	if ((n - 1) * (n - 2) / 2 < k) {
		cout << -1 << endl; return 0;
	}

	int m = n * (n - 1) / 2 - k;

	cout << m << endl;

	for (int i = 2; i <= n; i++) {
		cout << 1 << " " << i << endl;
	}

	int t = m - (n - 1);
	if(t > 0)
	for (int i = 2; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			cout << i << " " << j << endl;
			t--;
			if (t == 0) break;
		}
		if (t == 0) break;
	}

	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

ll h;

ll f(ll x) {
	if (x == 0)
		return 0;
	return 2 * f(x / 2) + 1;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> h;
	cout << f(h) << endl;
	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

pair<ll,ll> L[222222];
pair<ll,ll> R[222222];

int main(){
	
	int n;cin >> n;
	
	vector<ll> v(n);
	vector<ll> sv(n);
	
	REP(i,n){
		cin >> v[i];
		sv[i] = v[i];
	}
	
	REP(i,n-1)sv[i+1] += sv[i];
	
	ll now_s = v[0];
	ll now_p = 0;
	for(ll i = 1;i < n;i++){
		while(now_p < i-1 && abs(2*now_s-sv[i]) > abs(2*(now_s+v[now_p+1]) - sv[i])){
			now_p++;
			now_s += v[now_p];
		}
		L[i] = MP(now_s,sv[i] - now_s);
	}
	
	now_p = n-1;
	now_s = v[n-1];
	
	for(ll i = n-2;i > 0;i--){
		while(now_p > i+1 && abs(2*now_s-(sv[n-1]-sv[i-1])) > abs(2*(now_s+v[now_p-1]) - (sv[n-1]-sv[i-1]))){
			now_p--;
			now_s += v[now_p];
		}
		R[i] = MP(now_s,(sv[n-1] - sv[i-1]) - now_s);
	}
	
	ll ans = LLINF;
	
	for(int i = 1;i < n-2;i++){
		ll ma = max(max(L[i].FI,L[i].SE),max(R[i+1].FI,R[i+1].SE));
		ll mi = min(min(L[i].FI,L[i].SE),min(R[i+1].FI,R[i+1].SE));
		ans = min(ans,ma - mi);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9984
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static Scan sc = new Scan();
    static void Main()
    {
        int n, k;
        sc.Multi(out n, out k);
        Prt(sc.IntArr.OrderBy(x => x).Skip(n - k).Sum());
        sw.Flush();
    }
    static void Prt(string a) { sw.WriteLine(a); }
    static void Prt<T>(IEnumerable<T> a) { Prt(string.Join(" ", a)); }
    static void Prt(params object[] a) { Prt(string.Join(" ", a)); }
}
class Scan
{
    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
    public string Str { get { return Console.ReadLine().Trim(); } }
    public int[] IntArr { get { return StrArr.Select(int.Parse).ToArray(); } }
    public long[] LongArr { get { return StrArr.Select(long.Parse).ToArray(); } }
    public double[] DoubleArr { get { return StrArr.Select(double.Parse).ToArray(); } }
    public string[] StrArr { get { return Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); } }
    bool eq<T, U>() { return typeof(T).Equals(typeof(U)); }
    T ct<T, U>(U a) { return (T)Convert.ChangeType(a, typeof(T)); }
    T cv<T>(string s) { return eq<T, int>()    ? ct<T, int>(int.Parse(s))
                             : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                             : eq<T, double>() ? ct<T, double>(double.Parse(s))
                             : eq<T, char>()   ? ct<T, char>(s[0])
                                               : ct<T, string>(s); }
    public void Multi<T>(out T a) { a = cv<T>(Str); }
    public void Multi<T, U>(out T a, out U b)
    { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); }
}


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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;++i) cin>>a[i]>>b[i];
    for(int i=0;i<n-2;++i){
        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2]) return cout<<"Yes",0;
    }
    cout<<"No";
}

Measured memory_bytes: 3616
import sys
X, K, D = map(int, input().split())


N = abs(int(X / D))
if N >= K:
    print(min( abs(X - D * K), abs(X + D * K) ))
    sys.exit()

if X < 0:
    X = X + D * N
    ans1 = abs(X)
    ans2 = abs(X + D)
    if (K - N) % 2 == 0:
        print(ans1)
    else:
        print(ans2)

else:
    X = X - D * N
    ans1 = abs(X)
    ans2 = abs(X - D)
    if (K - N) % 2 == 0:
        print(ans1)
    else:
        print(ans2)



Measured memory_bytes: 9124
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	int t=a-2;
	ret+=t/11*5;
	for(int i=0;i<t%11;i++){
		for(int j=1;j<=5;j++){
			if((8+7*i+j)*9%11==b)ret++;
		}
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
bool isPrime(int x){
    if(x < 2) return false;
    if(x == 2) return true;
    if(x%2 == 0) return false;
    for(int i=3; i*i<=x; i++){
        if(x%i == 0) return false;
    }
    return true;
}
int main(){
    int n;
    while(cin >> n){
        if(n == 0) break;
        if(isPrime(n)) {
            cout << 0 << endl;
            continue;
        }
        int cp = n,cp1 = n;
        int left = 0,right = 0;
        int flag_left=0,flag_right=0;
        while(1){
            if(left != 0 && right != 0) break;
            if(flag_left < 1) cp--;
            if(flag_right < 1) cp1++;
            if(isPrime(cp)) {
                left = cp;
                flag_left++;
            }
            if(isPrime(cp1)){
                right = cp1;
                flag_right++;
            }
        }
        cout << right-left << endl;
    }
    return 0;
}



Measured memory_bytes: 3080
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9+7
pos = [*filter(lambda x: x>=0, A)]
neg = [*filter(lambda x: x<0, A)]
pos.sort(reverse=True)
neg.sort()

ans = 1
i,j = 0,0
while i+j < K:
    flag = True
    if i == len(pos):
        flag = False
    elif j == len(neg):
        flag = True
    elif pos[i] < -neg[j]:
        flag = False

    if flag:
        ans = ans * pos[i] % m
        i += 1
    else:
        ans = ans * neg[j] % m
        j += 1

if j % 2 == 0 or N==K:
    print(ans)
elif len(pos) == 0:
    ans = 1
    for i in range(K):
        ans = ans * neg[len(neg)-1-i] % m
    print(ans)
else:
    flag2 = True
    if i == 0:
        flag2 = True
    elif j == 0:
        flag2 = False
    elif i == len(pos):
        flag2 = False
    elif j == len(neg):
        flag2 = True
    elif pos[i-1]*pos[i] < neg[j-1]*neg[j]:
        flag2 = False

    if flag2:
        ans = (ans * pow(neg[j-1],m-2,m) % m) * pos[i] % m
    else:
        ans = (ans * pow(pos[i-1],m-2,m) % m) * neg[j] % m
    print(ans)

Measured memory_bytes: 31892
/*input
3 2 1
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let mut v: Vec<u32> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect(""))
        .collect();
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}



Measured memory_bytes: 5036
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int main(void)
{
	//変数の宣言
	int n;
	int a,b,c,d;
	int edge[1000][2];
	int e;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	if(n==3){
		printf("2\n1 3\n2 3\n");
		return 0;
	}else if(n==4){
		printf("4\n");
		printf("1 3\n");
		printf("4 3\n");
		printf("1 2\n");
		printf("4 2\n");
		return 0;
	}else if(n%2==0){
		flag=0;
		e=0;
		for(i=1;i<n/2;i++){
			a=i;
			b=n-a+1;
			c=(i+1);
			d=n-c+1;
			edge[e][0]=a;
			edge[e][1]=c;
			edge[e+1][0]=a;
			edge[e+1][1]=d;
			edge[e+2][0]=b;
			edge[e+2][1]=c;
			edge[e+3][0]=b;
			edge[e+3][1]=d;
			e=e+4;
		}
		a=1;
		b=n-a+1;
		edge[e][0]=a;
		edge[e][1]=c;
		edge[e+1][0]=a;
		edge[e+1][1]=d;
		edge[e+2][0]=b;
		edge[e+2][1]=c;
		edge[e+3][0]=b;
		edge[e+3][1]=d;
		e=e+4;
	}else{
		flag=0;
		e=0;
		for(i=1;i<n/2;i++){
			a=i;
			b=n-a;
			c=(i+1);
			d=n-c;
			edge[e][0]=a;
			edge[e][1]=c;
			edge[e+1][0]=a;
			edge[e+1][1]=d;
			edge[e+2][0]=b;
			edge[e+2][1]=c;
			edge[e+3][0]=b;
			edge[e+3][1]=d;
			e=e+4;
		}
		a=n;
		edge[e][0]=a;
		edge[e][1]=c;
		edge[e+1][0]=a;
		edge[e+1][1]=d;
		e=e+2;
		c=1;
		d=n-c;
		edge[e][0]=a;
		edge[e][1]=c;
		edge[e+1][0]=a;
		edge[e+1][1]=d;
		e=e+2;
	}




	//	printf("計算部分終了\n");

	//出力

	printf("%d\n",e);
	for(i=0;i<e;i++){
		printf("%d %d\n",edge[i][0],edge[i][1]);
	}

	
	//	printf("結果の出力終了\n");

	return 0;
}



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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    string S,day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int i;

    cin>>S;

    for(i = 0;i < 7;i++){
        if(S == day[i]){
            cout<<7 - i<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256