akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int L;
string s,t;
main()
{
	cin>>L>>s>>t;
	if(L==s.size())
	{
		string ans=s;
		if(L%t.size()==0)
		{
			string tmp=t;
			while(tmp.size()<L)tmp+=t;
			if(ans>tmp)ans=tmp;
		}
		cout<<ans<<endl;
	}
	else if(L==t.size())
	{
		string ans=t;
		if(L%s.size()==0)
		{
			string tmp=s;
			while(tmp.size()<L)tmp+=s;
			if(ans>tmp)ans=tmp;
		}
		cout<<ans<<endl;
	}
	else
	{
		string ss=s,tt=t;
		while(ss.size()<L)ss+=s;
		while(tt.size()<L)tt+=t;
		if(ss>tt)swap(s,t);
		for(int i=L/s.size();;i--)
		{
			if((L-s.size()*i)%t.size()==0)
			{
				string ans="";
				for(int j=0;j<i;j++)ans+=s;
				while(ans.size()<L)ans+=t;
				cout<<ans<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 1544
#include <iostream>
using namespace std;
int main()
{
    long long int a, b, x, div;
    cin >> a >> b >> x;
    if(a == 0) {
        div = b / x;
        div = div + 1;
        cout << div;
    } else {
        div = b / x;
        div = div - (a - 1) / x;
        cout << div;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	string S; cin >> S;
	if (S[0] == S[1] && S[1] == S[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

char A[16][1024];

int main() {
	int h, w, k, r = 1234; cin >> h >> w >> k;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> A[i][j];
	for(int msk = 0; msk < (1 << (h - 1)); msk++) {
		vector<int> g(h);
		int x = 0;
		for(int i = 0; i < h; i++) {
			g[i] = x;
			if(msk & (1 << i)) x++;
		}
//		cout << x << " " << k << endl;
		int C[w][x + 1], a = __builtin_popcount(msk), y = 0;
		vector<int> D(x + 1);
		for(int i = 0; i < w; i++)
			for(int j = 0; j <= x; j++)
				C[i][j] = 0;
		for(int i = 0; i < w; i++) {
			for(int j = 0; j < h; j++)
				C[i][g[j]] += A[j][i] == '1';
			for(int j = 0; j <= x; j++) {
				if(C[i][j] > k) a = 12345;
				else y = max(y, D[j] += C[i][j]);
			}
			if(y <= k) continue;
			for(int j = 0; j <= x; j++)
				D[j] = C[i][j];
			y = 0;
			a++;
//			cout << msk << ": " << a << endl;
		}
		r = min(r, a);
	}
	cout << r;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = max(0, c - (a - b));
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

static const int tops[4][3] = {{1,2,3},{3,6,9},{7,8,9},{1,4,7}};
static const int long_sides[4][3] = {{21,20,19},{15,14,13},{10,11,12},{16,17,18}};
static const int short_sides[4] = {16,19,13,10};

void rotate(int cell[31],int pattern_i){
  for(int i = 0; i < 3; i++){
    swap(cell[31 - tops[pattern_i][i]],cell[tops[pattern_i][2 - i]]);
  }
  swap(cell[long_sides[pattern_i][0]],cell[long_sides[pattern_i][2]]);
  swap(cell[31-short_sides[pattern_i]],cell[short_sides[pattern_i]]);
}

bool check(int cell[31]){
  for(int i = 1; i < 9; i++){
    if(cell[i] != cell[i+1]) return false;
  }

  for(int i = 10; i < 12; i++){
    if(cell[i] != cell[i+1]) return false;
  }

  for(int i = 13; i < 15; i++){
    if(cell[i] != cell[i+1]) return false;
  }

  for(int i = 16; i < 18; i++){
    if(cell[i] != cell[i+1]) return false;
  }

  for(int i = 19; i < 21; i++){
    if(cell[i] != cell[i+1]) return false;
  }

  for(int i = 22; i < 30; i++){
    if(cell[i] != cell[i+1]) return false;
  }
  return true;
}
 

int dfs(int cell[31],int depth){
  if(depth > 8) return INF;
  if(check(cell)){
    return depth;
  }

  int res = INF;
  int prev[31];
  memcpy(prev,cell,sizeof(int)*31);
  for(int pattern_i = 0; pattern_i < 4; pattern_i++){
    rotate(cell,pattern_i);
    res = min(res,dfs(cell,depth+1));
    memcpy(cell,prev,sizeof(int)*31);
  }
  return res;
}

void debug(int cell[31]){
  printf(" %d%d%d    \n",cell[21],cell[20],cell[19]);
  printf("%d%d%d%d%d%d%d%d\n",cell[16],cell[1],cell[2],cell[3],cell[15],cell[28],cell[29],cell[30]);
  printf("%d%d%d%d%d%d%d%d\n",cell[17],cell[4],cell[5],cell[6],cell[14],cell[25],cell[26],cell[27]);
  printf("%d%d%d%d%d%d%d%d\n",cell[18],cell[7],cell[8],cell[9],cell[13],cell[22],cell[23],cell[24]);
  printf(" %d%d%d    \n",cell[10],cell[11],cell[12]);
  printf("\n");
}

int main(){
  int total_test_cases;
  while(~scanf("%d",&total_test_cases)){
    for(int test_i = 0; test_i < total_test_cases; test_i++){
      int cell[31];
      for(int cell_i = 1; cell_i <= 30; cell_i++){
        int num;
        scanf("%d",&num);
        cell[cell_i] = num;
      }
      printf("%d\n",dfs(cell,0));
    }
  }
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <string.h>

int main(void){

  char number[1001];
  int i;
  int s;
  int len;
  while(1){
    for(i=0;i<1001;i++){
      number[i] = '0';
    }

    scanf("%s", number);
   if(*number == '0'){break;}
   else {
     s = 0;
     len = strlen(number);
     for(i=0;i<len;i++){
     s = s + number[i] - '0';
     }
   printf("%d\n", s);
   }
  }

  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

ll gcd(ll a, ll b){
	if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
	return a*b/gcd(a, b);
}

int main(){
	int n, m;
	cin >> n >> m;
	ll a[n];
	int b[n];
	fill(b, b+n, 0);
	for(int i=0; i<n; i++){
		cin >> a[i];
		a[i]/=2;
		while(a[i]%2==0){
			a[i]/=2;
			b[i]++;
		}
	}
	sort(b, b+n);

	if(b[0]!=b[n-1]){
		cout << 0 << endl;
		return 0;
	}

	ll l=a[0]*(1<<b[0]);
	for(int i=1; i<n; i++){
		l=lcm(l, a[i]);
		if(l>m){
			cout << 0 << endl;
			return 0;
		}
	}

	ll t=m/l;
	cout << (t+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 1408
using System;

class Transfer
{
    static void Main (string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);

        int left;

        left = c - (a - b);

        if (left <= 0)
            left = 0;

        Console.WriteLine(left);
    }
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, N; cin >> D >> N;
    int idx = 0;
    for(int i = 1;;i++){
        int val = i;
        int cnt = 0;
        while(val > 0 && val % 100 == 0){
            val/=100;
            cnt++;
        }
        if(cnt == D) idx++;
        if(idx == N){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0) {
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main() {
  char a[1300];
  int i = 0, j = 0;
  
  while (1) {
    scanf("%c", &a[j]);
    if (a[j] == '\n') break;
    j++;
  }

  for (i = 0; i < j; i++) {
    if ('A' <= a[i] && a[i] <= 'Z') {
      a[i] += 32;
    } else if ('a' <= a[i] && a[i] <= 'z') {
      a[i] -= 32;
    }
  }

  for (i = 0; i < j; i++) {
    printf("%c", a[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;
import java.util.regex.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input=new Scanner(System.in);
		String str=input.nextLine();
		String pattern=".*C.*F.*";
		if(Pattern.matches(pattern,str)) System.out.println("Yes");
		else System.out.println("No");
   }
}

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

class Cube {
public:
	int f[6];
	Cube(){}
	void roll_z() { roll(1, 2, 4, 3); }
	void roll_y() { roll(0, 2, 5, 3); }
	void roll_x() { roll(0, 1, 5, 4); }
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void move(char ch) {
		if (ch == 'E')for (int i = 0; i < 3; i++)roll_y();
		if (ch == 'W')roll_y();
		if (ch == 'N')roll_x();
		if (ch == 'S')for (int i = 0; i < 3; i++)roll_x();
	}
};

int main()
{
	Cube c;
	string com;

	for (int i = 0; i < 6; i++)cin >> c.f[i];
	cin >> com;

	for (int i = 0; i < com.size(); i++)c.move(com[i]);

	cout << c.f[0] << endl;

    return 0;
}



Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  int64_t N;
  cin>>N;
  if(400<= N && N <= 599 )cout<<8<<endl;
  if(600<= N&& N <= 799 )cout<<7<<endl;
  if(800<= N&& N <= 999 )cout<<6<<endl;
  if(1000<= N&& N <= 1199 )cout<<5<<endl;
  if(1200<= N&& N <= 1399 )cout<<4<<endl;
  if(1400<= N&& N <= 1599 )cout<<3<<endl;
  if(1600<= N && N<= 1799 )cout<<2<<endl;
  if(1800<= N && N<= 1999 )cout<<1<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const int INF = 1 << 30;
const LL LLINF = 1LL << 60;
using namespace std;


int main(void){
    LL N, T;
    cin >> N >> T;

    vector<LL> t(N);
    rep(i, N) cin >> t[i];

    LL ans = 0;
    for(int i = 1; i < N; i++) {
        ans += min(T,t[i] - t[i-1]);
    }
    ans += T;

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

int solve(vector<pair<P, char>> p, char x, char y, int coeff) {
	sort(all(p));
	int res = inf / 5 + 10;
	int n = p.size();
	int i = 0;
	while (i < n) {
		int idx = i;
		vector<int> a, b;
		while (i < n && p[i].first.first == p[idx].first.first) i++;
		for (int j = idx; j < i; j++) {
			if (p[j].second == x) a.pb(p[j].first.second);
			if (p[j].second == y) b.pb(p[j].first.second);
		}
		sort(all(a)); sort(all(b));
		b.pb(inf);
		for (int val : a) {
			int mi = lower_bound(all(b), val) - b.begin();
			chmin(res, b[mi] - val);
		}
	}
	return res * coeff;
}

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

	int n;
	cin >> n;
	vector<pair<P, char>> p(n);
	rep(i, n) cin >> p[i].first.first >> p[i].first.second >> p[i].second;
	int ans = inf;
	vector<pair<P, char>> q = p;
	chmin(ans, solve(q, 'U', 'D', 5));
	q = p;
	rep(i, n) swap(q[i].first.first, q[i].first.second);
	chmin(ans, solve(q, 'R', 'L', 5));
	rep(i, n) {
		q[i].first.first = p[i].first.first - p[i].first.second;
		q[i].first.second = p[i].first.first;
	}
	chmin(ans, solve(q, 'U', 'L', 10));
	chmin(ans, solve(q, 'R', 'D', 10));
	rep(i, n) {
		q[i].first.first = p[i].first.first + p[i].first.second;
		q[i].first.second = p[i].first.second;
	}
	chmin(ans, solve(q, 'U', 'R', 10));
	chmin(ans, solve(q, 'L', 'D', 10));
	if (ans == inf) cout << "SAFE\n";
	else cout << ans << '\n';
}

Measured memory_bytes: 18464
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j;
  string s,t;
  
  cin >> s >> t;
  
  n=s.size();
  
  for (i=0;i<n;i++){
    for (j=0;j<n;j++){
      if (s[(i+j)%n]!=t[j]) break;
    }
    if (j==n) break;
  }
  
  if (i!=n) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
const int mod=1e9+7;
 
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    int ans=0;
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++){
    	if(s[i]!=t[i])ans++;
    }
    cout<<ans;

    
}





Measured memory_bytes: 3724
Mod = 10**9+7
n,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
a = 0
for i in range(n):
  a = (a+x[i]*(2*i+1-n))%Mod
b = 0
for i in range(m):
  b = (b+y[i]*(2*i+1-m))%Mod
print((a*b)%Mod)
  

Measured memory_bytes: 18624
use std::collections::VecDeque;
 
fn main() {
  let mut char_vec: VecDeque<char> = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().to_owned().chars().collect()
  };
  
  let Q = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_end().to_owned().parse::<usize>().unwrap()
  };
  
  let mut flag = true;
  for _ in 0..Q {
    let s = {
      let mut s = String::new();
      std::io::stdin().read_line(&mut s).unwrap();
      s.trim_end().to_owned()
    };

    let ws: Vec<&str> = s.split_whitespace().collect();
    if ws.len() == 1 {
       flag = !flag;
    } else {
       if ws[1] == "1" {
         if flag {
           char_vec.push_front(ws[2].chars().next().unwrap());
         } else {
           char_vec.push_back(ws[2].chars().next().unwrap());         
         }
         
       } else {
         if flag {
           char_vec.push_back(ws[2].chars().next().unwrap());
         } else {
           char_vec.push_front(ws[2].chars().next().unwrap());
         }
       };
    }  
  }
  
  let mut a: Vec<char> = char_vec.into_iter().collect();
  if !flag {
 	a.reverse();
  }
  let a: String = a.iter().collect();
  println!("{}", a);
}

Measured memory_bytes: 4836
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(){
	string str;
	while(getline(cin,str) && str != "."){
		vector<char> c;
		for(int i = 0 ; i < str.size() ; i++)
			if(str[i] == ')' || str[i] == '(' || str[i] == '[' || str[i] == ']')
				c.push_back(str[i]);
		stack<char> s;
		bool f = true;
		for(int i = 0 ; i < c.size() ; i++)
			if(s.size() == 0 || c[i] == '(' || c[i] == '[')
				s.push(c[i]);
			else if(c[i] == ')' && s.top() == '('){
				s.pop();
			}else if(c[i] == ']' && s.top() == '['){
				s.pop();
			}else{
				f = false;
			}
			cout << (f && s.empty() ?"yes":"no") << endl;
	}
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) cout << "a > b"<< endl;
	if (a < b) cout << "a < b" << endl;
	if (a == b) cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
long long dp[300][300],sum[300][300];
long long a[300];
long long n,l,r;
int main()
{
    for(int i=0;i<=200;i++)
    {
        sum[0][i]=0;
        sum[i][0]=1;
        sum[i][i]=1;
    }
    for(int i=0;i<=200;i++)
    {
        for(int j=0;j<=200;j++)
        {
            dp[i][j]=-1;
        }
    }
    dp[0][0]=0;
    cin>>n>>l>>r;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=0;
        for(int j=1;j<=i&&j<=r;j++)
        {
            long long x=dp[i-1][j];
            long long y=dp[i-1][j-1]+a[i];
            if(x==y)
            {
                dp[i][j]=x;
                sum[i][j]=sum[i-1][j]+sum[i-1][j-1];
            }
            else if(x>y)
            {
                dp[i][j]=x;
                sum[i][j]=sum[i-1][j];
            }
            else
            {
                dp[i][j]=y;
                sum[i][j]=sum[i-1][j-1];
            }
        }
    }
    int pos=0;
    long long k=0;
    for(int i=l;i<=r&&i<=n;i++)
    {
        if(pos==0)
        {
            pos=i;
            k=sum[n][i];
        }
        else if(dp[n][i]*pos>dp[n][pos]*i)
        {
            pos=i;
            k=sum[n][i];
        }
        else if(dp[n][i]*pos==dp[n][pos]*i)
        {
            k+=sum[n][i];
        }
    }
    printf("%.6f\n",dp[n][pos]*1.0/pos*1.0);
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string a,b;
    cin >> a >> b;
    for (int i = 0; i < 3; ++i) {
        if (a[i] != b[2-i]) {cout << "NO\n"; return 0;}
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int room[4][3][10]{ 0 }, n, b, f, r, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (j == 3) {
				if (i == 3)continue;
				for (int k = 0; k < 20; k++)cout << "#";
			}
			else for (int k = 0; k < 10; k++)cout << " " << room[i][j][k];
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;

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

    bool flag = false;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N - a; b++) {
            if (Y == 10000 * a + 5000 * b + 1000 * (N - a - b)) {
                flag = true;
                cout << a << " " << b << " " << N - a - b << endl;
            }
            if (flag) {
                break;
            }
        }
        if (flag) {
            break;
        }
    }

    if (flag == false) {
        cout << "-1 -1 -1" << endl;
    }
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
    for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int) (1e9) + 7;

void _() {
    ill(r);
    ill(c);
    char a[r][c];
    for (int i = 0; i < r; ++i) {
        scanf("%s",&a[i]);
    }
    for (ll i = 0; i < r; ++i) {
        for (ll j = 0; j < c; ++j) {
            if(a[i][j]=='#' &&a[i][max(0ll,j-1)]=='.' && a[max(0ll,i-1)][j]=='.'
               && a[min(r-1,i+1)][j]=='.'   && a[i][min(c-1,j+1)]=='.' ){
                cout << "No" ;
                return;
            }
        }
    }
    cout << "Yes";

};


int main() {
#if __MINGW32__
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Input.txt", "r", stdin);
    freopen("E:\\Workspace\\Desktop\\cpp\\IO\\Output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
def main():
    N = input()
    L = input().split()

    cnt = 0

    for i in range(len(L)):
        iValue = L[i]
        for j in range(i + 1, len(L)):
            jValue = L[j]
            for k in range(j + 1, len(L)):
                kValue = L[k]
                rl = [int(iValue), int(jValue), int(kValue)]
                rl.sort()
                if iValue != jValue and jValue != kValue and iValue != kValue:
                    if (int(rl[0]) + int(rl[1])) > int(rl[2]):
                        # print(rl)
                        cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68440
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int A,B,C;
	cin >> A >> B >> C;
	cout << min(C,B/A) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
ll x[100006];
ll y[100006];
ll pre[100006];
ll cfind(ll a) {
  if (pre[a] != a) pre[a] = cfind(pre[a]);
  return pre[a];
}

void cunion(ll a, ll b) {
  ll r1 = cfind(a);
  ll r2 = cfind(b);
  pre[r1] = r2;
}

ll dist(ll x1, ll y1, ll x2, ll y2) {
  return min(abs(x1 - x2), abs(y1 - y2));
}
ll pdist(ll p1, ll p2) {
  return dist(x[p1], y[p1], x[p2], y[p2]);
}

ll calc() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
  }
  vector<pair<int, int>> edges;
  edges.reserve(2 * N);
  for (int i = 0; i < N; ++i) pre[i] = i;
  vector<int> ind(N);
  iota(ind.begin(), ind.end(), 0);
  sort(ind.begin(), ind.end(),
       [](const int i1, const int i2) { return x[i1] < x[i2]; });

  for (int i = 0; i < N - 1; ++i) {
    ll a = ind[i];
    ll b = ind[i + 1];
    if (a > b) swap(a, b);
    edges.push_back({a, b});
  }
  sort(ind.begin(), ind.end(),
       [](const int i1, const int i2) { return y[i1] < y[i2]; });
  for (int i = 0; i < N - 1; ++i) {
    ll a = ind[i];
    ll b = ind[i + 1];
    if (a > b) swap(a, b);
    edges.push_back({a, b});
  }
  sort(edges.begin(), edges.end());
  int len = unique(edges.begin(), edges.end()) - edges.begin();
  edges.resize(len);

  sort(edges.begin(), edges.end(), [](const pair<int,int> &p1, const pair<int,int> &p2){
    ll dist1 = pdist(p1.first, p1.second);
    ll dist2 = pdist(p2.first, p2.second);
    return dist1 < dist2;
  });

  ll ret = 0;
  // cout << "edges' size" << edges.size() << endl;
  int ct = 0;
  for(auto const &e: edges) {
    int p1 = e.first;
    int p2 = e.second;

    if (cfind(p1) == cfind(p2)) continue;
    // cout << "p1, p2, dist: " << p1 << ' ' << p2 << ' ' << pdist(p1, p2) << endl;
    cunion(p1, p2);
    ct++;
    ret += pdist(p1, p2);
    if (ct == N - 1) break;
  }
  assert(ct == N - 1);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  cout << calc() << endl;

}

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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3

c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

if (c1[1]-c1[0] == c2[1]-c2[0] == c3[1]-c3[0]) and \
   (c2[2]-c2[1] == c2[2]-c2[1] == c3[2]-c3[1]) and \
   (c2[0]-c1[0] == c2[1]-c1[1] == c2[2]-c1[2]) and \
   (c3[0]-c2[0] == c3[1]-c2[1] == c3[2]-c2[2]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		// ?????? A ??\???
		int[][] A;
		A = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		// ?????? B ??\???
		int[][] B;
		B = new int[m][l];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}

		// ?????? C ??\???
		// long ?????????
		long[][] C;
		C = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					C[i][j] = C[i][j] + A[i][k] * B[k][j];
				}
			}
		}

		// ?????? C ??????
		for (int i = 0; i < n; i++) {

			// C[i][j]???1???????????????????????????(" " + C[i][j])?????????
			int j = 0;
			System.out.print(C[i][j]);

			for (j = 1; j < l; j++) {
				System.out.print(" " + C[i][j]);
			}
			System.out.println();
		}

	}

}

Measured memory_bytes: 51876
# めぐる二分探索
def lower_bound(a, key):
    ng = -1
    ok = len(a)
    
    while abs(ok-ng)>1:
        mid = (ok + ng) // 2
        
        if a[mid]>key: ok=mid # 今回は真に大きいだから不等号
        else: ng = mid
    return ok

def upper_bound(a, key):
    ng = len(a)
    ok = -1
    
    while abs(ok-ng)>1:
        mid = (ok + ng) // 2
        
        if a[mid]<key: ok=mid # 今回は真に大きいだから不等号
        else: ng = mid
    return ok

N = int(input())
A, B, C = [sorted(list(map(int, input().split()))) for _ in range(3)]
ans = 0
for b in B:
    a_i = upper_bound(A, b)
    c_i = lower_bound(C, b)
    ans += (a_i+1)*(N-c_i)
print(ans)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    int2(x, y);
    vector<int> data(n);
    int hoge = x;
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        hoge = max(hoge, data[i]);
    }
    vector<int> yui(m);
    int huga = y;
    for (int i = 0; i < m; i++) {
        cin >> yui[i];
        huga = min(huga, yui[i]);
    }

    if (hoge < huga) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }
    


    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        friends: [(usize, usize); m],
    }

    let mut uf = UnionFind::new(n);
    for (a, b) in friends {
        let a = a - 1;
        let b = b - 1;
        uf.unite(a, b);
    }

    let mut group_member = vec![0i64; n];
    for i in 0..n {
        let group = uf.find(i);
        group_member[group] += 1;
    }
    let ans: i64 = group_member.iter().max().copied().unwrap();
    println!("{}", ans);
}

struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut parent = vec![];
        for i in 0..n {
            parent.push(i);
        }
        UnionFind {
            parent: parent,
            rank: vec![0; n],
        }
    }

    fn find(&mut self, i: usize) -> usize {
        if self.parent[i] == i {
            i
        } else {
            let p_i = self.parent[i];
            self.parent[i] = self.find(p_i);
            self.parent[i]
        }
    }

    fn unite(&mut self, i: usize, j: usize) {
        let i = self.find(i);
        let j = self.find(j);
        if i == j {
            return;
        }

        if self.rank[i] < self.rank[j] {
            self.parent[i] = j;
        } else {
            self.parent[j] = i;
            if self.rank[i] == self.rank[j] {
                self.rank[i] += 1;
            }
        }
    }

    fn same(&mut self, i: usize, j: usize) -> bool {
        self.find(i) == self.find(j)
    }
}


Measured memory_bytes: 10736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct union_find {
    ll par[MAX_N];
    ll Size[MAX_N];
    void init(ll n) {
        for (int i = 0; i < n; i++) {//úť
            par[i] = i;
            Size[i] = 1;
        }
    }
    ll root(ll x) {
        if (par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
    void unite(ll x, ll y) {
        if (same(x, y))return;
        par[root(y)] = root(x);
        Size[root(x)] = Size[root(y)];
    }
};
int main() {
    union_find U;
    cin >> n >> q;
    U.init(n);
    rep(i, q) {
        cin >> x >> a >> b;
        if (x == 0)U.unite(a, b);
        else cout << (U.same(a, b) ? 1 : 0)<< endl;
    }
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  ll ans = 0;
  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g <= n; j++) {
      ll tmp = n - (i * r + j * g);
      if (tmp >= 0 && tmp % b == 0) {
        ans++;
      }
    }
  }

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


Measured memory_bytes: 256
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++) { a[i] = stdIn.nextInt(); } Arrays.sort(a); long s = 0; for(int i = 0; i < n; i++) { s += a[i]; } System.out.println(a[0] + " " + a [n-1] + " " + s ); } } 


Measured memory_bytes: 42176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
void read(int &x) {
	char ch; bool ok;
	for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
	for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
#define rg register
const int maxn=1e5+10;bool vis[maxn];
int n,k,dep[maxn],ans,f[maxn],cnt,pre[maxn*2],nxt[maxn*2],h[maxn];
void add(int x,int y){
	pre[++cnt]=y,nxt[cnt]=h[x],h[x]=cnt;
}
void dfs(int x){
	vis[x]=1;dep[x]=1;
	for(rg int i=h[x];i;i=nxt[i])
		if(!vis[pre[i]])dfs(pre[i]),dep[x]=max(dep[pre[i]]+1,dep[x]);
	if(dep[x]>=k&&f[x]!=1)dep[x]=0,ans++;
}
int main()
{
	read(n),read(k);scanf("%d",&f[1]);
	for(rg int i=2;i<=n;i++)read(f[i]),add(f[i],i);
	if(f[1]!=1)ans++,f[1]=1;dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 5376
#include <stdio.h>
int main(void)
{
	int n,a1,a2,a3,a4,a5;
	scanf("%d",&n);
	if(n==10 || n==100 || n==1000 || n==10000 || n==100000){
		printf("10\n");
	}else{
		a1=n/10000;
		a2=n/1000%10;
		a3=n/100%10;
		a4=n/10%10;
		a5=n%10;
		printf("%d\n",a1+a2+a3+a4+a5);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

bool binarySearch(int A[], int n, int key) {
    auto left = 0;
    auto right = n;
    int mid;

    while(left < right){
        mid = (left + right) / 2;

        if (key == A[mid]) {
            return true;
        }
        if (key > A[mid]) {
            left = mid + 1;
        } else if (key < A[mid]) {
            right = mid;
        }
    }
    return false;
}

int main() {
    int i, q, k;
    int n;
    auto sum = 0;
    int A[1000000];

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

    scanf("%d", &q);

    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(A, n, k)) {
            sum++;
        }
    }
    printf("%d\n", sum);
    
    return 0;
}



Measured memory_bytes: 2976
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

int main(){
	int L, R;
	cin>>L>>R;
	int mi = 20e+9 + 2;
	for(int i = L; i <= R; i++){
		for(int j = i; j <= R; j++){
			if(i == j)continue;
          if(j % 2019 == 0){
            cout<<0<<endl;
            return 0;
          }
			mi = min(mi , ((i % 2019) * (j % 2019))%2019);
		}
	}
	cout<<mi%2019<<endl;
}


Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

ans = 10 ** 18
for i in range(max(X, Y) + 1): #ABピザを2 * i枚買う
    tmp = 2 * i * C
    x = max(0, X - i)
    y = max(0, Y - i)
    tmp += x * A + y * B
    ans = min(ans, tmp)

print (ans)

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

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

    int res = 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i) == t.at(i))
            res++;
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;


int main(){

  ll n;cin>>n;
  ll a;
  ll r=0;
  while(n--){
    cin>>a;
    r^=a;
  }
  if(!r)out("Yes")
  else out("No")

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

vector<int> eratosthenes(int n){
	bool arr[n];
	for(int i = 0; i <= n; i++){
		arr[i] = true;
	}
	arr[0] = false; arr[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(arr[i]){
			for(int j = i * 2; j <= n; j += i){
				arr[j] = false;
			}
		}
	}
	vector<int> primes;
	for(int i = 0; i <= n; i++){
		if(arr[i]) primes.push_back(i);
	}
	return primes;
}

int a[100001];

int main(){
	vector<int> v, t;
	v = eratosthenes(100000);
	Rep(i, v.size()){
		int k = (v[i] + 1) / 2;
		bool flag = false;
		Rep(j, v.size()){
			if(v[j] == k){
				flag = true;
				break;
			}else if(v[j] > k){
				break;
			}
		}
		if(flag) t.pb(v[i]);
	}
	Rep(i, t.size()){
		a[t[i]] += 1;
	}
	Rep(i, 100000){
		a[i + 1] += a[i];
	}
	int q; cin >> q;
	Rep(i, q){
		int x, y; cin >> x >> y;
		cout << a[y] - a[x - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a;i<=b;++i)
#define rep(i, n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  int n, m;
  int max = 0;
  cin >> n;
  map<string, int> mp;
  rep(i, n){
    string s; cin >>s;
    mp[s] += 1;
  }
  cin >> m;
  rep(i, m){
    string s; cin >>s;
    mp[s] -= 1;
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(max <= itr->second)  max = itr->second;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
#define		_CRT_SECURE_NO_WARNINGS
#include	<cstdio>
#include	<cmath>

using namespace std;

int main()
{
	double	X1, X2, Y1, Y2;

	scanf("%lf %lf %lf %lf", &X1, &Y1, &X2, &Y2);

	printf("%.8f\n", sqrt((X2 - X1) * (X2 - X1) + (Y2 - Y1) * (Y2 - Y1)));

	return 0;
}

Measured memory_bytes: 2732
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int turn = 0;
    while(true){
        if(turn % 2 == 0){
            c -= b;
            if(c <= 0){
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if(a <= 0){
                cout << "No" << endl;
                return 0;
            }
        }
        turn++;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
const int INF = 1e9;
const long long MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

ll ret[100][100];

void comb() {
  for (int i = 0; i < 100; i++) {
    ret[i][0] = 1;
    ret[i][i] = 1;
  }
  for (int j = 1; j < 100; j++) {
    for (int k = 1; k < j; k++) {
      ret[j][k] = (ret[j-1][k-1] + ret[j-1][k]);
    }
  }
  return;
}

template<typename T> 
void print(vector<T> &x) {
    int n = x.size();
    REP(i,n) {
        if (i != n-1) cout << x[i] << " ";
        else cout << x[i] << endl;
    }
}

int main(int argc, char const *argv[]) {
    int n, a, b;
    cin >> n >> a >> b;
    map<ll, ll> mp;
    vector<ll> v(n);
    REP(i,n) {
        cin >> v[i];
        mp[v[i]]++;
    }
    sort(v.begin(), v.end(), greater<>());

    long double ave = 0.0;
    ll cnt = 0;

    REP(i,a) ave += v[i];
    ave/=a;
    memset(ret, 0, sizeof(ret));
    comb();

    if (v[0] == v[a-1]) {
        ll x = min((ll)b, mp[v[0]]);
        for (int i = a; i <= x; ++i) {
            cnt += ret[mp[v[0]]][i];
        }
    }
    else {
        ll tmp = 0;
        REP(i,n-1) {
            if (v[i] != v[i+1]) tmp++;
            if (v[i+1] == v[a-1]) break;
        }
        cnt += ret[mp[v[a-1]]][a-tmp];
    }

    cout << fixed;
    cout << setprecision(10) << ave << endl;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
def main():
  n = int(input())
  a = [int(input()) for i in range(n)]
  check_id=1
  for i in range(1,n+1):
    check_id=a[check_id-1]
    if check_id==2:
      print(i)
      break
  if check_id!=2:
      print(-1)
main()

Measured memory_bytes: 12976
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <cmath>
#include <tuple>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 型
#define ll long long

// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// for文
#define forn(i, size) for (long long(i) = 0; (i) < (size); (i)++)
#define for0(size) for (long(i) = 0; (i) < (size); (i)++)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length, type_name) sort(array, array + length, std::greater<type_name>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)

// 結果出力系
#define YES                    \
    {                          \
        cout << "YES" << endl; \
        return 0;              \
    }
#define NO                    \
    {                         \
        cout << "NO" << endl; \
        return 0;             \
    }
#define Yes                    \
    {                          \
        cout << "Yes" << endl; \
        return 0;              \
    }
#define No                    \
    {                         \
        cout << "No" << endl; \
        return 0;             \
    }
#define println(str) cout << str << endl;

#pragma endregion

#pragma region Utility
#pragma region 最大公約数
ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
#pragma endregion

#pragma region 最小公倍数
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
#pragma endregion

#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion

#pragma region 連想配列のkeyが存在するか
template <typename T>
bool containsKey(map<string, T> map, string key)
{
    if (map.count(key) == 0)
    {
        return false;
    }
    return true;
}
#pragma endregion

#pragma region 素数判定
bool isPrime(ll num)
{
    for (int i = 2; i < num / 2 + 1; i++)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}
#pragma endregion
#pragma endregion

int main()
{
    // 標準入力から値を取得
    int N;
    cin >> N;

    for (int i = N; i < N + 100; i++)
    {
        if (isPrime(i))
        {
            println(i);
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

// gcd
template <class T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main()
{
    ll A, B;
    cin >> A >> B;
    ll d = gcd(A, B);
    cout << A * B / d << endl;
}

Measured memory_bytes: 256