akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	string a, b; cin >> a >> b; a += b;
	int n = stoi(a);
	
	int pos = 1;
	while(pos * pos < n) pos++;
	
	if(pos * pos == n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
  cin >> s;
  int data[26];
  for(int i = 0; i < 26; i++) data[i] = 0;
  bool flag;
  for(int i = 0; i < 4; i++){
    data[s[i]-'A']++;
  }
  int cnt = 0;
  for(int i = 0; i < 26; i++){
   if(data[i] == 2) cnt++; 
  }
  if(cnt == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
//#endif
    string s;
    getline(cin, s);
    string t;
    for(auto x : s) {
        if(t.size()>0 && t.back() == 'S' && x=='T') {
            t.pop_back();
        }
        else t.pb(x);
    }
    cout << t.size();
    
    
}



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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  int ans = 1001001001;
  for(int i = -1; i <= 1; i++){
    int tmp = 0;
    for(int j = 0; j < n; j++){
      tmp += (a[j] - sum/n+i)*(a[j] - sum/n+i);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = Int32.Parse(input[0]);
            int A = Int32.Parse(input[1]);
            int B = Int32.Parse(input[2]);
            int trainMax = N * A;
            int taxiMax = B;
            int min = (trainMax < taxiMax) ? trainMax : taxiMax;
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double pi = acos(-1);
const double EPS = 1e-10;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    if (i % 2 == 0) {
      a /= 2;
      b += a;
    } else {
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>

#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


struct graph {
	
	int n;
	vector<int> *adj;
	
	graph(int V) {
		
		int n = V;
		adj = new vector<int>[V];
	}
	
	void AddEdge (int u,int v) {
		
		adj[u].pb(v);
		adj[v].pb(u);
	}
};

void DFS (int index, int last, int ans[], vector<int> &DP, int value[], graph &g) {
	
	int lower = lower_bound(DP.begin(), DP.end(), value[index]) - DP.begin();
	int prev = DP[lower];
	DP[lower] = value[index];
	ans[index] = lower_bound(DP.begin(), DP.end(), 1<<30) - DP.begin();
	vector<int>::iterator it;
	for (it = g.adj[index].begin(); it != g.adj[index].end(); it++) {
		if (*it != last)
			DFS(*it, index, ans, DP, value, g);
	}
	
	DP[lower] = prev;
}

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    ll n, a, b;
    cin >> n;
    
    graph g(n);
    
    int value[n], ans[n] = {0};
    
    rep(i, n) cin >> value[i];
    
    rep(i, n - 1) {
    	
    	cin >> a >> b;
    	a--;
    	b--;
    	g.AddEdge(a,b);
	}
	
	ans[0] = 1ll;
	
	vector<int> DP(n + 1, 1<<30);
		
	DFS(0, -1, ans, DP, value, g);
	
	rep(i, n)
		cout << ans[i] << "\n";
	
	//code
	return 0;
}


Measured memory_bytes: 33784
#include<iostream>
#include<cstdio>
#include<sstream>
#include<map>
#include<set>
#include<algorithm>
#define _3_ true
using namespace std;

int main(){
  int n;
  string s;
  map<string,int> dic;
  multimap<int,string,greater<int> > TheM;
  char han;

  while(_3_){
    cin >> n;
    cin.ignore();
    if(n == 0)break;
    for(int i=0;i<n;i++){
      getline(cin,s);
      stringstream ss(s);
      while(ss >> s){
	dic[s]++;
	//cout << "s =" <<s << endl;
      }
    }
    cin >> han;
    int count=0;
    int kuhaku=0;
    map<string,int>::iterator it = dic.begin();
    while(it != dic.end()){
      TheM.insert(multimap<int,string,greater<int> >::value_type((*it).second,(*it).first));
		  if((*it).first[0] == han){
		    kuhaku++;
		  }    
      it++;
    }
	
    
	
	multimap<int,string>::iterator itm = TheM.begin();
      while(itm != TheM.end()){
	if((*itm).second[0] == han){
	  cout << (*itm).second;
	  count++;
	if(count < 5  && count < kuhaku){cout << " ";}
	}
	  itm++;
	if(count >= 5)break;
      }
      if(count == 0)cout << "NA";
      cout << endl;

      TheM.clear();
      dic.clear();

  }

  return 0;
}

Measured memory_bytes: 956
use std::cmp::min;
use std::collections::HashMap;
use std::io::*;

fn rec(x: u128, a: u128, b: u128, c: u128, d: u128, map: &mut HashMap<u128, u128>) -> u128 {
    if let Some(val) = map.get(&x) {
        return *val;
    } else {
        let mut res = x * d;
        res = min(res, rec(x / 2, a, b, c, d, map) + a + x % 2 * d);
        if x % 2 != 0 {
            res = min(res, rec(x / 2 + 1, a, b, c, d, map) + a + (2 - x % 2) * d);
        }
        res = min(res, rec(x / 3, a, b, c, d, map) + b + x % 3 * d);
        if x % 3 != 0 {
            res = min(res, rec(x / 3 + 1, a, b, c, d, map) + b + (3 - x % 3) * d);
        }
        res = min(res, rec(x / 5, a, b, c, d, map) + c + x % 5 * d);
        if x % 5 != 0 {
            res = min(res, rec(x / 5 + 1, a, b, c, d, map) + c + (5 - x % 5) * d);
        }
        map.insert(x, res);
        res
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let t: usize = itr.next().unwrap().parse().unwrap();
    let mut out = Vec::new();
    for _ in 0..t {
        let n: u128 = itr.next().unwrap().parse().unwrap();
        let a: u128 = itr.next().unwrap().parse().unwrap();
        let b: u128 = itr.next().unwrap().parse().unwrap();
        let c: u128 = itr.next().unwrap().parse().unwrap();
        let d: u128 = itr.next().unwrap().parse().unwrap();

        let mut map = HashMap::new();
        map.insert(0, 0);
        map.insert(1, d);
        writeln!(out, "{}", rec(n, a, b, c, d, &mut map)).ok();
    }
    stdout().write_all(&out).unwrap();
}


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

int main() {
  string s;
  ll k;
  cin >> s >> k;
  char ans = '1';
  int i = 0;
  while(s[i] == '1' && i < (int)s.size()) i++;
  if (k > i) ans = s[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    std::cin >> s;
    int len=s.length();
    for (int i = 1; i <= len; i++) {
        if(i%2==0){
            if(s[i-1]=='R'){
                std::cout << "No" << std::endl;
                return 0;
            }
        }else{
            if(s[i-1]=='L'){
                std::cout << "No" << std::endl;
                return 0;
            }
            
        }
    }
    std::cout << "Yes" << std::endl;
}


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

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		for(int i=a;i<=b;i++){
			if(c%i==0){
				ans++;
			}
		}
		System.out.println(ans);
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    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 static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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() {
        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 (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 24312
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int time=0;
	while (n > 0) {
		n -= x;
		time += t;
	}
	cout << time << endl;
	return 0;
}

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

using namespace std;

const int mod = 1'000'000'007;

int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int a[200'009];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    int j = n - 1 - i;
    int cur = 0;
    cur = mul(j, pw(2, j - 1));
    cur = add(cur, pw(2, j));
    cur = mul(cur, pw(4, i));
    cur = mul(cur, pw(2, j + 1));
    cur = mul(cur, a[i]);
    ans = add(ans, cur);
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;
const ll INF = 1e19;

void chmin(ll &a, ll b){
  if(a > b) a = b;
}

int main() { 
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
    if(i) a[i] += a[i-1];
  }

  ll ans = INF;
  rep(i, n-1){
    chmin(ans, abs(a[n-1] - a[i]*2));
  }
  cout << ans << endl;
  return 0;
}

/*
9
2-7...7-2
6-3...3-6
*/

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
const int maxv=2005,mod=1000000007;
int v,dp[maxv];
int main()
{
	cin>>v;
	dp[0]=1;
	for(int i=3;i<=v;i++)
		for(int j=3;i-j>=0;j++)
			dp[i]+=dp[i-j],dp[i]%=mod;
	cout<<dp[v]<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  
  int s, u, d;
  char ;
  
  scanf("%d" ,&s);
  
  u = s / 100;//上二桁
  d = s % 100;//下二桁
  
  //printf("%d %d %d\n", s, u, d);
  
  if((u > 12 || u == 0) && d <= 12  && d >= 1){printf("YYMM\n");} 
  
  else if(u <= 12 && (d > 12 || d == 0) && u >= 1){printf("MMYY\n");} 
  
  else if(u <= 12 && d <= 12 && u >= 1 && d >= 1){printf("AMBIGUOUS\n");} 
  
  else{printf("NA\n");} 
  
  return 0;
  
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = int.Parse(Console.ReadLine());
            var cnt = 1;
            var hash = new HashSet<int>();
            hash.Add(s);
            while(true)
            {
                s = s % 2 == 0 ? s / 2 : 3 * s + 1;
                cnt++;
                if(hash.Contains(s))
                {
                    Console.WriteLine(cnt);
                    break;
                }
                else
                {
                    hash.Add(s);
                }
            }
        }

    }
}
//A

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
   char s[51];
   scanf("%s",s);
   for(int i=0;i<strlen(s)-8;i++){
       cout<<s[i];
   }
   cout<<endl;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll s;
	cin>>s;
	vector<ll>dp(s+1,1);
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	for(ll i=3;i<=s;i++){
		for(ll j=3;j<=i-3;j++){
			dp[i]+=dp[j];
			dp[i]%=mod;
		}
	}
	cout<<dp[s]<<endl;



	return 0;
}

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

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

    int n, m;
    cin >> n >> m;
    vector<int> votes(n);
    rep(i, n) cin >> votes[i];

    int all_vote = 0;
    for (auto vote : votes) all_vote += vote;

    // check
    int count = 0;
    for (auto vote : votes) {
        if ((vote * 4 * m) >= all_vote) {
            count++;
        }
    }

    if (count >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a,b;
	int e;
	cin >> a >> b;
	if (a == 0 && b != 100){
		cout << b << "\n";
	}
	else if(a == 1 && b != 100){
		cout << 100 * b << "\n";
	}
	else if(a == 2 && b != 100){
		cout << 10000 * b << "\n";
	}
	else if (a == 0 && b == 100) {
		cout << "101" << "\n";
	}
	else if (a == 1 && b == 100) {
		cout << "10100" << "\n";
	}
	else if (a == 2 && b == 100) {
		cout << "1010000" << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E5+7;
const long long INF = 1E18;

long long f[N][4];
long long a[N], b[N], c[N];
int n;

int main()
{
    fastIO;
    cin>>n;
    
    for (int i = 1;i <= n;++i) cin>>a[i]>>b[i]>>c[i];
    
    for (int i = 0;i <= n;++i)
        for (int j = 1;j <= 3;++j) f[i][j] = -INF;
    
    long long tmp = 0;
    int save = 0;
    if (tmp < a[1]) { tmp = a[1]; save = 1; }
    if (tmp < b[1]) { tmp = b[1]; save = 2; }
    if (tmp < c[1]) { tmp = c[1]; save = 3; }
    
    f[1][save] = tmp;
    
    for (int i = 2;i <= n;++i)
        for (int j = 1;j <= 3;++j)
        {
            if (j == 1) f[i][j] = max(f[i][j],max(f[i-1][j+1]+a[i],f[i-1][j+2]+a[i]));
            if (j == 2) f[i][j] = max(f[i][j],max(f[i-1][j-1]+b[i],f[i-1][j+1]+b[i]));
            if (j == 3) f[i][j] = max(f[i][j],max(f[i-1][j-1]+c[i],f[i-1][j-2]+c[i]));
        }
    
    long long res = 0;
    for (int i = 1;i <= 3;++i) res = max(res,f[n][i]);
    
    cout<<res;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) std::cerr << #x << " = " << x << std::endl

using namespace std;
using ll = long long;

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

    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1));

    rep(i, N) rep(j, W + 1) {
        if (j - w[i] >= 0)
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        else
            dp[i + 1][j] = dp[i][j];
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>

int main(){
  int i = 0;
  int n = 0;
  int k = 0;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    if(n <= k + (k-1)*i){
      break;
    }
  }
  
  printf("%d",i+1);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main()
{
	int a, b, h, m;
	double c,hx,mx,x;
	scanf("%d%d%d%d", &a, &b, &h, &m);

	mx = (double)m * 6;
	hx = 0.5 * ((double)h * 60 + m);
	if (mx > hx)
	{
		x = mx - hx;
	}
	else
	{
		x = hx - mx;
	}

	if (m==0&&h==0)
	{
		printf("%d\n", abs(a - b));
	}
	else
	{
		c = sqrt((double)a * (double)a + (double)b * (double)b - 2.0 * (double)a * (double)b * cos((double)x * PI / 180.0));
		printf("%.11lf\n", c);
	}
	
	return 0;
}

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

using namespace std;

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

    string s;
    cin >> s;
    int w;
    cin >> w;
    int n = s.size();
    for(int i = 0; i < n; i += w)
        cout << s[i];

    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())

dp = []
dp.append(K*(2*N-K+1)//2-K*(K-1)//2+1)
for k in range(K+1,N+1+1):
    s_min = k*(k-1)//2
    s_max =  k*(2*N-k+1)//2
    dp.append((dp[k-1-k]+s_max-s_min+1)%(10**9+7))

ans = dp[-1]
print(ans)

Measured memory_bytes: 78688
using System;
using System.Collections.Generic;
using System.Linq;

class Pg
{
    static void Main()
    {
        string line;
        while (!string.IsNullOrEmpty(line = Console.ReadLine()))
        {
            var n = line.Trim().Split().Select(int.Parse).ToArray();
            var count = 0;
            for (int i = 1; i <= 10; i++)
            {
                if (n.Any(x => x == i))
                {
                    continue;
                }
                if (n[0] + n[1] + i <= 20)
                {
                    count++;
                }
            }
            Console.WriteLine(count >= 4 ? "YES" : "NO");
        }
    }
}




Measured memory_bytes: 18432
n = int(input())
a = list(map(int,input().split()))

ans = 1
now = 1

s = sum(a)
if a[0] == 1 and n != 0:
    ans = -1
elif n == 0:
    if a[0] == 1:
        ans = 1
    else:
        ans = -1
if n == 1 and a[1] >= 3:
    ans = -1

else:
    for i in range(n):
        s -= a[i]
        if a[i] > now:
            ans = -1
            break
        elif s <= (now-a[i])*2:
            now = s
            ans += now
        else:
            now = (now-a[i])*2
            ans += now
        if i == n-1:
            if now != a[-1]:
                ans = -1
print(ans)

Measured memory_bytes: 20152
#include <cstdio>
#include <cstring>
const int BASE = 10;
const int DIVS = 13;
const int MAXS = 1e5+5;
const int MOD = 1e9+7;
const int REM = 5;
char buff[MAXS];
int dp[MAXS][DIVS];
int S;

void place(int i, int msb) {
  for (int k = 0; k < DIVS; ++k) {
    int pos = (msb + k * BASE) % DIVS;
    dp[i][pos] = (1LL * dp[i-1][k] + dp[i][pos]) % MOD;
  }
}

int solve() {
  for (int i = 0; i <= S; ++i) {
    for (int j = 0; j < DIVS; ++j) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;

  for (int i = 1; i <= S; ++i) {
    if (buff[i] == '?') {
      for (int j = 0; j < BASE; ++j) {
        place(i, j);
      }
    } else {
      place(i, buff[i]-'0');
    }
  }
  return dp[S][REM];
}

int main() {
  scanf(" %s", buff+1);
  S = strlen(buff+1);
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 5376
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N=23;
const int Mod=1e9+7;
int n;
bool g[MAX_N][MAX_N];
LL dp[MAX_N][1<<MAX_N];
/*int dfs(int now,int S)
{
	if(now==n)
	{
	//	cout<<S<<endl;
		return 1;
	}
	if(dp[now][S])return dp[now][S];
	for(int i=0;i<n;i++)
	{
		if(g[now][i] && (S&(1<<i)))dp[now][S]+=dfs(now+1,S&(~(1<<i)));
		dp[now][S]%=Mod;
	}
	return dp[now][S];
}*/
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>g[i][j];
		}
	}
//	int ans=dfs(0,(1<<n)-1);
	//cout<<ans<<endl;
	dp[0][(1<<n)-1]=1;
	for(int i=0;i<n;i++)
	{
		for(int S=0;S<(1<<n);S++)
		{
			if(__builtin_popcount(S)!=n-i)continue;
			for(int j=0;j<n;j++)
			{
				if(g[i][j] && (S&(1<<j)))
				{
					dp[i+1][S&(~(1<<j))]+=dp[i][S];
					dp[i+1][S&(~(1<<j))]%=Mod;
				}
			}
		}
	}
	cout<<dp[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 285440
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);		
		int K = a.nextInt();
		int A = a.nextInt();
		int B = a.nextInt();
		int num = 0;
		for(int i = A ; i <= B; i++) {
			if(i % K == 0) {
				num++;
			}
		}
		if(num > 0) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
	}
}

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

using namespace std;

struct edge{
  int to,cap,cost,rev;
};

const int INF=1<<29;
int N,L;
int NV;
vector<vector<edge> > G;

void add_edge(int from,int to,int cap,int cost){
  G[from].push_back({to,cap,cost,(int)G[to].size()});
  G[to].push_back({from,0,-cost,(int)G[from].size()-1});
}

int min_cost_flow(int s,int t){
  int nc=0;
  for(int c=1;;c++){
    int dist[2002];
    fill(begin(dist),end(dist),INF);
    dist[0]=0;
    int prevv[2002],preve[2002];
    bool update=true;
    while(update){
      update=false;
      for(int v=0;v<NV;v++){
	if(dist[v]==INF)continue;
	for(int i=0;i<G[v].size();i++){
	  edge &e=G[v][i];
	  if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
	    dist[e.to]=dist[v]+e.cost;
	    prevv[e.to]=v;
	    preve[e.to]=i;
	    update=true;
	  }
	}
      }
    }
    nc-=dist[t];
    if(nc==L)return c;
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap--;
      G[v][e.rev].cap++;
    }
  }
}

int main(){
  for(int M;cin>>N>>M>>L,N;){
    NV=2*L+2;
    int d[100][100];
    fill(d[0],d[100],INF);
    for(int i=0;i<N;i++){
      d[i][i]=0;
    }
    while(M--){
      int u,v,di;
      cin>>u>>v>>di;
      d[u][v]=d[v][u]=min(d[u][v],di);
    }
    for(int k=0;k<N;k++){
      for(int i=0;i<N;i++){
	for(int j=0;j<N;j++){
	  d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	}
      }
    }
    G=vector<vector<edge> >(NV);
    vector<pair<int,int> > pt;
    for(int i=0;i<L;i++){
      int p,t;
      cin>>p>>t;
      pt.emplace_back(t,p);
    }
    sort(begin(pt),end(pt));
    for(int i=0;i<pt.size();i++){
      add_edge(0,2*i+2,1,0);
      add_edge(2*i+2,2*i+3,1,-1);
      add_edge(2*i+3,1,1,0);
      for(int j=0;j<i;j++){
	if(pt[j].first+d[pt[j].second][pt[i].second]<=pt[i].first){
	  add_edge(2*j+3,2*i+2,1,0);
	}
      }
    }
    cout<<min_cost_flow(0,1)<<endl;
  }
}

Measured memory_bytes: 21324
#include<stdio.h>

int n;
int a[10000000];

int binarySearch(int key)
{
	int min = 0;
	int max = n;
	int mid;
	while(min < max)
	{
		mid = (min + max) / 2;
		if(key == a[mid]) return 1;
		if(key > a[mid])
		{
			min = mid + 1;
		}
		else if(key < a[mid])
		{
			max = mid;
		}
	}
	return 0;
}
int main(void)
{
	int i, q, key;
	int c = 0;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	scanf("%d", &q);
			
	for(i = 0; i < q; i++)
	{
		scanf("%d", &key);
		if(binarySearch(key)) c++;
	}
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 2224
#include <iostream>

using namespace std;

int main(void) {
	int num, i = 0, buf, mi = 0, ma, d[13] = { 0 };
	cin >> num;
	for (; i < num; i++) {
		scanf("%d", &buf);
		d[buf / 400]++;
	}
	ma = d[8] + d[9] + d[10] + d[11] + d[12];
	for (i = 0; i < 8; i++) {
		if (d[i] > 0)
			mi++;
	};
	ma += mi;
	if (mi == 0)
		mi = 1;
	printf("%d %d\n", mi, ma);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
int main() {
  string S,T;
  cin >> S >> T;
  int s=S.length();
  int t=T.length();
  //cout << s << " " << t;
  int Max=0;
  int count=0;
  for(int i=0;i<=s-t;i++){
    count=0;
    for(int j=0;j<t;j++){
      if(S[i+j]==T[j]){
        count++;
      }
    }
    if(count>Max){
      Max=count;
    }
  }
  cout << t-Max;
  cout << endl;
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int N,P; cin>>N>>P;//O(nlog(n)) cuz n=2*10^5;
  string S; cin>>S;

  if(10%P==0){
    ll ans = 0;
    rep(r,N){
      if((S.at(r)-'0')%P==0){
        ans += r+1;
      }
    }
    cout<<ans<<endl;
    return 0;
  }

  vector<ll> dp(N+1);
  int ten = 1;
  for(int i = N-1; i >= 0; i--){
    int a = (S.at(i)-'0')*ten%P;
    dp.at(i) += (dp.at(i+1)+a) % P;
    ten *= 10; ten %= P;
  }
  map<ll,ll> m;
  for(auto i: dp){
    if(m.count(i))m[i]++;
    else m[i]=1;
  }

  ll res = 0;
  for(auto p: m){
    ll num = p.second;
    res += (num-1)*num/2;
  }

  cout<<res<<endl;
}

Measured memory_bytes: 2564
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int[] move_1=new int[n];
		int[] move_N=new int[n];
		Arrays.fill(move_1, 0);
		Arrays.fill(move_N, 0);
		
		for(int i=0;i<m;i++){
			int a=sc.nextInt()-1;
			int b=sc.nextInt()-1;
			if(a==0)
				move_1[b]=1;
			if(b==n-1)
				move_N[a]=1;
		}
		for(int i=0;i<n;i++){
			if(move_1[i]==1 && move_N[i]==1){
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}

Measured memory_bytes: 96540
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define double long double
using namespace std;
const int N = 301;
//const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}
string s;
int used[N][N][N];
int mem[N][N][N];

int dfs(int l,int r,int k){
  if(l > r) return 0;

  if(used[l][r][k]++) return mem[l][r][k];
  int res = 0;
  int f = l < r;
  if(k) Max(res,1 + f + dfs(l+1,r-1,k-1));
  if(s[l] == s[r]) Max(res,1 +f +  dfs(l+1,r-1,k));

  Max(res,dfs(l+1,r,k));
  Max(res,dfs(l,r-1,k));
  return mem[l][r][k] = res;
}

signed main(){
  int K;
  cin>>s>>K;
  int ans = dfs(0,s.size()-1,K);
  cout<<ans<<endl;
  
  return 0;
}


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

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

    int p[m], y[m];
    vector<int> pre[n+1];

    for(int i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        pre[p[i]].push_back(y[i]);
    }

    for(int i = 1; i <= n; i++) sort(pre[i].begin(), pre[i].end());

    for(int i = 0; i < m; i++){
        int pos = (lower_bound(pre[p[i]].begin(), pre[p[i]].end(), y[i]) - pre[p[i]].begin())+1;
        cout << setw(6) << right << setfill('0') << p[i];
        cout << setw(6) << right << setfill('0') << pos << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
const int maxn=1e9+7;
ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)ans = (ans % m) * (a % m) % m;
        b /= 2;
        a = (a % m) * (a % m) % m;
    }
    ans %= m;
    return ans;
}
ll inv(ll x, ll p)
{
    return pow(x, p - 2, p);
}
ll C(ll n, ll m, ll p)
{
    if(m > n)return 0;
    ll up = 1, down = 1;
    for(int i = n - m + 1; i <= n; i++)up = up * i % p;
    for(int i = 1; i <= m; i++)down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}


int main(){
   ll n,a,b;
   cin>>n>>a>>b;
   ll sum=pow(2,n,maxn)-1;
   ll ca=Lucas(n,a,maxn);
   ll cb=Lucas(n,b,maxn);
   sum-=(ca+cb);
   sum%=maxn;
   if(sum<0)sum+=maxn;
   cout<<sum<<endl;
} 

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    real[4] x,y;
    auto n = to!int(chomp(readln()));
    for(int j=0;j<n;j++){
	auto s = split(readln());
	for(int i=0;i<4;i++){
	    x[i] = to!real(s[2*i]);
	    y[i] = to!real(s[2*i+1]);
	}
	real[2] AB,CD;
	bool flg = false;
	AB[0] = x[1] - x[0];
	AB[1] = y[1] - y[0];
	CD[0] = x[3] - x[2];
	CD[1] = y[3] - y[2];

	if(AB[0] == 0 || CD[0] == 0){
	    if(AB[0] == CD[0]) flg = true;
	}else if( AB[1]*CD[0] - CD[1]*AB[0] == 0) flg = true;

	if(flg) writeln("YES");
	else writeln("NO");
    }
}

Measured memory_bytes: 2312
// #include <iostream>
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int mx = x2 - x1; 
    int my = y2 - y1;
    // if(mx != my){
        x3 = x2 - my;
        y3 = y2 + mx;
        // cout << "mx : " << mx << '\n';
        // cout << "my : " << my << '\n';
        cout << x3 << " " << y3 << " ";
        x4 = x3 - mx;
        y4 = y3 - my;
        cout << x4 << " " << y4 << '\n'; 
    // }else{

    // }
    
    
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define mp make_pair
#ifndef MY
    #define endl '\n'
#endif
//#define int long long
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double db;
typedef long double ldb;
typedef pair < int, int > pii;

ostream & operator << (ostream & out, vector < int > & lst) {
    for (auto a : lst)
        out << a << ' ';
    out << endl;
    return out;
}

const db PI = 3.1415926535897932384626433832795;
const int T = 360;

signed main() {
#ifdef MY
    freopen("f.in", "r", stdin);
    //freopen("f.out", "w", stdout);
#endif // MY
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    db a, b, h ,m;
    cin >> a >> b >> h >> m;
    db p = 30.0 * h + 30.0 * (m / 60.0);
    db q = 360.0 * (m / 60.0);
    db d = abs(p - q);
    db cs = d * PI / 180.0;
    //cout << d << ' ' << cs<< endl;
    db ans = a * a + b * b - 2 * a * b * cos(cs);
    ans = sqrt(ans);
    cout << fixed << setprecision(20);
    cout << ans;
    return 0;
}


Measured memory_bytes: 4164
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define ll long long

ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
int main(int argc, char** argv) {
	ll k;
	cin>>k;
	ll sum=0;
	rep(i,1,k)
	{
		rep(j,1,k)
		{
			rep(l,1,k)
			{
			sum+=gcd(gcd(i,j),l);	
			
				
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main () {
  char c[2][3];
  for (int i = 0; i < 2; i ++) {
    for (int j = 0; j < 3; j ++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < 3; i ++) {
    if (c[0][i] != c[1][2 - i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D_AddAndRemove solver = new D_AddAndRemove();
        solver.solve(1, in, out);
        out.close();
    }

    static class D_AddAndRemove {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            out.println(a[0] + a[n - 1] + f(a, 0, n - 1, 1, 1));
        }

        private long f(int[] a, int l, int r, long x, long y) {
            if (r - l == 1) {
                return 0;
            }
            long res = Long.MAX_VALUE;
            for (int i = l + 1; i < r; i++) {
                res = Math.min(res, a[i] * (x + y) + f(a, l, i, x, x + y) + f(a, i, r, x + y, y));
            }
            return res;
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  int y[n];
  rep(i, n){
    cin>>y[i];}
  
  int ans=0;
  int rs=0;
  rep(i, n){
    if(i==0){
      rs=1;
    continue;}
    if(y[i]==y[i-1]){
      rs++;}
    else{
      ans+=rs/2;
      rs=1;}
  }
  if(rs>1){
    ans+=rs/2;}
  
  cout<<ans<<endl;
  return 0;
    
  
  
 
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    u = lines[0]

    return (u,)


def solve(u):
    
    result = ''.join(['x' for e in u])

    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

int main()
{
    int n;cin>>n;
    string s;
    string arr[4]={"AC" , "WA" ,"TLE" ,"RE" };
    int intarr[4]={};
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
            intarr[0]++;
        else if(s=="WA")
            intarr[1]++;
        else if(s=="TLE")
            intarr[2]++;
        else intarr[3]++;
    }
    for(int i=0;i<4;i++)
    {
        cout<<arr[i]<<" x "<<intarr[i]<<endl;
    }
    return 0;
}


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

int main(void)
{
	int N;
	cin >> N;
	int* X = new int[N];
	int* XX = new int[N];
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
		XX[i] = X[i];
	}

	sort(XX, XX + N);
	double chuo = (XX[N / 2] + XX[N / 2 - 1]) / 2.0;

	for (int i = 0; i < N; ++i) {
		if (X[i] <= chuo)	cout << XX[N / 2] << endl;
		else				cout << XX[N / 2 - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int MAXN = 100010;

int n, m;
vector<int> graph[MAXN];
int parent[MAXN];
bool visited[MAXN];

void solve() {
  cout << "Yes" << endl;

  queue<int> que;
  que.push(0);
  visited[0] = true;

  while (!que.empty()) {
    int cur = que.front();
    que.pop();
    for (int i=0;i<graph[cur].size();i++) {
      int v = graph[cur][i];
      if (!visited[v]) {
        visited[v] = true;
        parent[v] = cur;
        que.push(v);
      }
    }
  }
  for (int i=1;i<n;i++) {
    cout << parent[i] + 1 << endl;
  }
}

int main() {
  cin >> n >> m;
  for (int i=0;i<m;i++) {
    int a, b;
    cin >> a >> b;
    graph[--a].push_back(--b);
    graph[b].push_back(a);
  }
  solve();
}


Measured memory_bytes: 10508
N, M, Q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(M)]
pq = [list(map(int, input().split())) for _ in range(Q)]

matrix = [[0] * N for _ in range(N)]
for l, r in lr:
    l, r = l-1, r-1
    matrix[l][r] += 1

matrix2 = [[0] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if j == 0:
            matrix2[i][j] = matrix[i][j]
        else:
            matrix2[i][j] = matrix2[i][j-1] + matrix[i][j]

for p, q in pq:
    p, q = p-1, q-1
    count = 0
    for x in range(p, q + 1):
        count += matrix2[x][q]
    print(count)


Measured memory_bytes: 116056
import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
		int n = Integer.parseInt(first[0]);
		int k = Integer.parseInt(first[1]);
		int[] strength = new int[n];
		String[] second = br.readLine().split(" ", n);
		for (int i = 0; i < n; i++) {
		    strength[i] = Integer.parseInt(second[i]);
		}
		for (int i = 0; i < k; i++) {
		    int[] imos = new int[n];
		    for (int j = 0; j < n; j++) {
		        imos[Math.max(j - strength[j], 0)]++;
		        if (j + strength[j] + 1 < n) {
		            imos[j + strength[j] + 1]--;
		        }
		    }
		    for (int j = 1; j < n; j++) {
		        imos[j] += imos[j - 1];
		    }
		    strength = imos;
		    if (isFull(strength)) {
		        break;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    if (i > 0) {
		        sb.append(" ");
		    }
		    sb.append(strength[i]);
		}
		System.out.print(sb);
	}
	
	static boolean isFull(int[] arr) {
	    for (int x : arr) {
	        if (x < arr.length) {
	            return false;
	        }
	    }
	    return true;
	}
}


Measured memory_bytes: 63484
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
a = l.shift() * 1
b = l.shift() * 1 
c = l.shift() * 1 
k = inp.shift() * 1
cnt = 0;
while (cnt < k && a >= b) {
    b = b + b
    cnt++
} 
while (cnt < k && b >= c) {
    c = c + c
    cnt++
} 
console.log(a < b && b < c ? "Yes": "No")


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

int main(){
    double l;
    cin >> l;
    double ans;
    ans = pow((l/3),3.0);
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

using namespace std;

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

    vector<string> s(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }

    string x;
    cin >> x;

    int res = 0;
    for (int i = 0, j = 0; i < n; i++) {
        res += j * t[i];
        if (x == s[i]) {
            j = 1;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=998244353ll;
const int N=200005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}

int main(){
	int n;
	scanf("%d",&n);
	printf("%d",3*n*n);
	return 0;
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    string s;
    cin >> s;

    int ans = 10000;

    for (char c = 'a'; c <= 'z'; c++)
    {
        bool flag = false;

        for (int i=0;i<s.length();i++)
        {
            if (s[i] == c) flag = true;
        }

        if (!flag) continue;

        string t = s;
        int counter = 0;

        for (;;)
        {
            flag = false;
            for (int i=0;i<t.length();i++)
            {
                if (t[i] != c)
                {
                    flag = true;
                }
            }

            if (!flag) break;

            string cur = "";
            for (int i=0;i<t.length()-1;i++)
            {
                if ((t[i] == c) || (t[i+1] == c))
                {
                    cur += c;
                }
                else
                {
                    cur += t[i];
                }
            }
            t = cur;
            counter++;
        }
        ans = min(ans, counter);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main()
{
	int n;
	cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			sum+=i;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3596