akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,m;
  while(cin >> n >> m, n||m) {
    int ba[n];
    REP(i,n)
      cin >> ba[i];
    int now = 0;
    int sai[m];
    REP(i,m) {
      cin >> sai[i];
    }
    REP(i,m) {
      now += sai[i];
      if (now >= n-1) {
        cout << i+1 << endl;
        break;
      }
      now += ba[now];
      if (now >= n-1) {
        cout << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 0
#include <cstdio>
#
using namespace std;



/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */

int main () {
	int N;

	// 数字の個数の読込み
	scanf("%d", &N);
	//
	printf("%d\n", N*N*N);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  float N;
  cin>>N;
  float cnt=0;
  for(int i=1;i<=N;i++){
    if(i%2==1)cnt++;
  }
  printf("%.10f\n",cnt/N);
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);
    
    /* read */
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int sum = 0;
    if (a > b) {
      sum += a;
      a--;
    } else {
      sum += b;
      b--;
    }

    if (a > b) {
      sum += a;
      a--;
    } else {
      sum += b;
      b--;
    }
    os.println(sum);
  }
}

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

int main() {
  int N,K,s,i;
  cin >> N >> K;
  s = 1;
  for(i = 0; i <N; i ++){
    if(s < K)
      s *= 2;
    else
      s += K;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def main():
    n = int(input())
    hs = list(reversed(list(input_ints())))

    cost = [0, abs(hs[1] - hs[0])]

    for i in range(2, n):
        log(i)
        cost.append(min(cost[i - 2] + abs(hs[i] - hs[i - 2]), cost[i - 1] + abs(hs[i] - hs[i-1])))

    output(cost[-1])


main()


Measured memory_bytes: 13924
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n , m , q;
int x , y;

string s1 , s2;

int main() {
    cin >> n >> m >> q;
    cin >> x >> y;
    cin >> s1;
    cin >> s2;
    ///
    int yy = y;
    for(int i=0;i<q;i++){
        if(s1[i] == 'R'){
            ++yy;
        }
        if(yy > m){
            cout << "NO" << endl;
            return 0;
        }
        if(s2[i] == 'L'){
            if(yy > 1){
                --yy;
            }
        }
    }
    yy = y;
    for(int i=0;i<q;i++){
        if(s1[i] == 'L'){
            --yy;
        }
        if(yy < 1){
            cout << "NO" << endl;
            return 0;
        }
        if(s2[i] == 'R'){
            if(yy < m){
                ++yy;
            }
        }
    }
    ///
    int xx = x;
    for(int i=0;i<q;i++){
        if(s1[i] == 'D'){
            ++xx;
        }
        if(xx > n){
            cout << "NO" << endl;
            return 0;
        }
        if(s2[i] == 'U'){
            if(xx > 1){
                --xx;
            }
        }
    }
    xx = x;
    for(int i=0;i<q;i++){
        if(s1[i] == 'U'){
            --xx;
        }
        if(xx < 1){
            cout << "NO" << endl;
            return 0;
        }
        if(s2[i] == 'D'){
            if(xx < n){
                ++xx;
            }
        }
    }
    cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 776
let xn = readLine()!.split(separator: " ").map{Int($0)!}
let x = xn[0]
let n = xn[1]
let pArray = readLine()!.split(separator: " ").map{Int($0)!}
var lastSmallerX: Int!
var firstBiggerX: Int!

for i in 0...101 {
    if i > x {
        if pArray.contains(i) {
            continue
        } else {
            firstBiggerX = i
            break
        }
    } else {
        if pArray.contains(i) {
            continue
        } else {
            lastSmallerX = i
            continue
        }
    }
}

print(x - lastSmallerX <= firstBiggerX - x ? lastSmallerX! : firstBiggerX!)


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] == '?') s[i] = 'D';
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n)  for(int i = 0;i<n;++i)
#define fri(i,a,b) for(int i= a;i<=b;++i)
#define fro(i,a,b) for(int i= a;i>=b;--i)
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define fi first
#define se second
#define pb(x) push_back(x)
#define  mp(x,y) make_pair(x,y)
#define endl  "\n"
#define  ii  pair<int,int>
#define  LL  long long
#define  maxm(a,b,c)  max(a,max(b,c))
const int INF = 1e7+10;
int a[4] = {0,1,0,-1};
int b[4] = {1,0,-1,0};
int ans1 = 0,n,m,ans = 0;
char arr[21][21];
bool check(int x,int y){
	if((x<=n-1 and x>=0) and (y>=0 and y<=m-1) and arr[x][y] == '.')return true;
	return false;
}
int bfs(int x,int y){
int count1 = 0;
 bool vis[21][21];
memset(vis,false,sizeof(vis));
queue<pair<int,pair<int,int>>> q;
q.push(mp(0,mp(x,y)));
vis[x][y] = true;
while(!q.empty()){
   auto l = q.front();
   q.pop();
    count1 = l.fi;
    x = l.se.fi;
    y = l.se.se;
    ans = max(ans,count1);
   for(int i = 0;i<4;++i){
   	if(vis[x+a[i]][y+b[i]])continue;
   	if(check(x+a[i],y+b[i])){
   		q.push(mp(count1+1,mp(x+a[i],y+b[i])));
   		 vis[x+a[i]][y+b[i]] = true;
	   }
	  
   }	
}
return ans;
}
int main(){
	cin>>n>>m;
	int maxi = 0;
	fr(i,n){
		fr(j,m){
			cin>>arr[i][j];
		}
	}
	fr(i,n){
		fr(j,m){
			if(arr[i][j] == '.'){
			maxi = bfs(i,j);
			ans1 = max(maxi,ans1);
			ans = 0;
			
			}
		}
	}
  cout<<ans1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

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

  vector<int> graph[100001];
  deque<int> path;
  bool used[100001] = {0};

  Rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--; B--;

    if( i == 0 ) {
      path.pb( A ); path.pb( B );
      used[A] = true; used[B] = true; 
    }

    graph[A].pb( B );
    graph[B].pb( A );
  }


  while( 1 ) {
    bool flag = true;
    int end1 = path.front(), end2 = path.back();

    Rep(i, graph[end1].size()) {
      if( !used[graph[end1][i]] ) {
	path.pf( graph[end1][i] );
	used[graph[end1][i]] = true;
	flag = false;
	break;
      }
    }

    Rep(i, graph[end2].size()) {
      if( !used[graph[end2][i]] ) {
	path.pb( graph[end2][i] );
	used[graph[end2][i]] = true;
	flag = false;
	break;
      }
    }

    if( flag ) break;
  }

  cout << path.size() << endl;
  Rep(i, path.size()) cout << path[i]+1 << " ";
  cout << endl;
}


Measured memory_bytes: 7168
#include<cstdio>
#include<algorithm>
using namespace std;

int n, x, ans;
pair<int, int> v[111111];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		scanf("%d", &x);
		v[i]=make_pair(x, i%2);
	}
	sort(v,v+n);
	ans=0;
	for(int i=0;i<n;i++)
		ans+=(i%2) ^ v[i].second;
	printf("%d\n", ans/2);
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int n;
  cin >> n;
  cout << n / 2 + n % 2 << endl;
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

int N, Q;
ll x;
ll a[100005], sum[100005], jmp[100005];

bool check(int idx) {
	if (a[idx] < x) return false;
	ll t = abs(a[idx] - x);
	int lo = -1, hi = idx + 1;
	while (hi - lo > 1) {
		int mid = lo + (hi - lo) / 2;
		if (t < abs(x - a[mid])) lo = mid;
		else hi = mid;
	}
	return N - 1 - idx < idx - lo;
}


int main() {
	cin >> N >> Q;
	for (int i = 0; i < N; i++) cin >> a[i];
	for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
	for (int i = 0; i < N; i++) jmp[i + 1] = (i ? jmp[i - 1] : 0) + a[i];

	while (Q--) {
		cin >> x;

		int lo = -1, hi = N;
		while (hi - lo > 1) {
			int mid = lo + (hi - lo) / 2;
			if (check(mid)) hi = mid;
			else lo = mid;
		}

		ll ans = sum[N] - sum[hi];
		if (2*hi - N >= 0) ans += jmp[2*hi - N];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cstring>
using namespace std;
int mod=1000000007;
int main()
{
    int n;
    int a[200010];
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    long long sum[200010];
    memset(sum,0,sizeof(sum));
    for(int i=n;i>=1;i--)
        sum[i]=a[i]+sum[i+1]%mod;
    long long ans=0;
    for(int i=1;i<n;i++)
        ans=(ans+a[i]*sum[i+1]%mod)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5936
def calc(n):
  ret=n
  while ret>=3:
    ret=ret%3+ret//3
  return ret

n=int(input())
arr=list(map(int,input().split()))
cnt=[0]*(10**5+1)
for i in range(n):
  cnt[arr[i]]+=1
cnt1=0
cnt2=0
for i in range(10**5+1):
  tmp=calc(cnt[i])
  if tmp==1:
    cnt1+=1
  elif tmp==2:
    cnt2+=1
if cnt2%2==0:
  print(cnt1+cnt2)
else:
  print(cnt1+cnt2-1)

Measured memory_bytes: 14396
use std::mem::swap;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
    x: usize,
    y: usize,
    z: usize,
    );
    let (mut x,mut y, mut z) = (x, y, z);
    swap(&mut x, &mut y);
    swap(&mut x, &mut z);
    println!("{} {} {}", x, y, z);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    s64 d[n][n];
    s64 ans = 0;
    rep (i, n) rep (j, n) { cin >> d[i][j]; }

    rep (i, n) rep (j, n)
    {
        bool ok = true;
        rep (k, n)
        {
            if (i == k || j == k) continue;
            if (d[i][j] > d[i][k] + d[k][j])
            {
                cout << "-1\n";
                return 0;
            }
            else if (d[i][j] == d[i][k] + d[k][j])
            {
                ok = false;
            }
        }
        if (ok) ans += d[i][j];
    }

    cout << ans / 2 << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165
int main(){
  int A, B, H, M;
  long double At, Bt, rad;
  cin >> A >> B >> H >> M;
  //At = 30*H+(long double)M/(long double)2;//360*H/12 + 360/12*M/60
  //Bt = 6*M;//360*M/60
  //rad = (At-Bt)*PI/180;
  rad = (30*H+(long double)M/(long double)2-6*M)*PI/(long double)180;
  cout << setprecision(20) << sqrtl(A*A+B*B-2*A*B*cosl(rad));
}

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

typedef long long ll;

string S;
vector<int> cnt;

ll ans = 1;

int main() {
    cin >> S;

    cnt = vector<int>(26, 0);
    for(int i = S.size() - 1; i >= 0; i--) {
        for(int j = 0; j < 26; j++) {
            if(j == S[i] - 'a') continue;
            ans += cnt[j];
        }
        cnt[ S[i] - 'a' ]++;
    }
    cout << ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  int sum=0;
  cin>>N;
  int A[N],B[N-1];
  for(int i=0;i<(N-1);i++)
    cin>>B[i];
  for(int i=1;i<(N-1);i++)
  {
    A[i]=min(B[i-1],B[i]);
  }
  A[0]=B[0];
    A[N-1]=B[N-2];
  for(int i=0;i<N;i++)
    sum+=A[i];
  cout<<sum<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    vector<int> table;
    vector<ll> ans(n + 1, 0);
    for(int x = 1; x * x <= n; ++x){
        int S = x * x;
        for(int y = 1; y * y <= n; ++y){
            if(S + y * y + x * y >= n)  break;
            S += y * y + x * y;
            for(int z = 1; z * z <= n; ++z){
                if(S + z * z + x * z + y * z > n)   break;
                ++ans[S + z * z + x * z + y * z];
            }
            S -= y * y + x * y;
        }
    }
    
    for(int i = 1; i <= n; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 3596
use proconio::input;
use std::cmp::Reverse;

pub fn binom_knuth(n: usize, k: usize) -> usize {
    (0..n + 1)
        .rev()
        .zip(1..k + 1)
        .fold(1, |mut r, (n, d)| { r *= n; r /= d; r })
}

fn main() {
	input!(n: usize);
	input!(a: usize);
	input!(b: usize);
	input!(v: [usize; n]);

	let mut v = v;
	v.sort_by_key(|&x| Reverse(x));
	let mut v1 = v.clone();

	let mut sum: usize = 0;
	let v2 = v1.split_off(a);
	for i in 0..v1.len() {
		sum += v1[i];
	}
	//println!("{}", sum);
	//println!("{}", v1.len());
	println!("{}", sum as f64 / v1.len() as f64);

	if v1[0] == v1[v1.len()-1] {
		// vが全部同じ数xの場合
		// xの総数を数える。
		let mut sum = v1.len();
		for i in 0..v2.len() {
			if v2[i] != v1[0] {
				break;
			}
			sum += 1;
		}
		// 50Ca～50Cmin(b, xの総数)の総和
		let mut total = 0;
		for i in a..b+1{
			total += binom_knuth(sum, i);
		}
		println!("{}", total);
		return;
	}
	else {
		// そうでない場合
		// v最小値の総数Cv最小値のv内の個数
		let mut index = v1.len()-1;
		let mut count1 = 0;
		loop {
			if v1[index] != v1[v1.len()-1] {
				break;
			}
			count1 += 1;
			index -= 1;
		}
		let mut count2 = 0;
		for index in 0..v2.len() {
			if v2[index] != v1[v1.len()-1] {
				break;
			}
			count2 += 1;
		}
		//println!("1={}, 2={}", count1, count2);
		println!("{}", binom_knuth(count1+count2, count1));
	}
}



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

int vis[N],cnt[N],n,m,a[N];

int main(){
	cin>>n>>m;
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		for(int j=max(1,i-cnt[i]+1);j<=i;j++){
			vis[j]++;
		}
	}
	int ret=0;
	for (int i = 1; i <= n; i++) {
		if(!vis[i])ret++;
	}
	for (int i = 0; i < m; i++){
		int x,y;
		cin>>x>>y;
		if(a[x]-cnt[a[x]]+1>0 && --vis[a[x]-cnt[a[x]]+1]==0)ret++;
		cnt[a[x]]--;
		cnt[y]++;
		if(y-cnt[y]+1>0 && ++vis[y-cnt[y]+1]==1)ret--;
		cout<<ret<<endl;
		a[x]=y;
	}
	return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        String S = scanner.next();
        int a[] = new int[Q];
        int b[] = new int[Q];
        for(int i=0;i<Q;i++){
            a[i] =scanner.nextInt();
            b[i] =scanner.nextInt();
        }
        int t[] = new int[N+1];
        String find ="AC";
        for(int i=0;i<N;i++) {
            if(i==0){t[i]=0;}
            if(i>=1 && S.substring(i-1,i+1).equals(find)){
                t[i] = 1;}
            else{t[i] = 0;
            }
        }
        int s[] = new int[N+1];
        for(int i =0;i<N;i++){
            if(i==0){s[i]=t[i];}else{
                s[i] = t[i] + s[i-1];
                }
        }
        for(int i=0;i<Q;i++){
            System.out.println(s[b[i]-1]-s[a[i]-1]);
        }
    }
}

Measured memory_bytes: 83064
/*****************************************************************************************
******************************AUTHOR:***************************************************
****************************ASHISH RANJAN***********************************************
*****************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define fr(i,n) for(int i=0;i<(int)n;i++)
#define meme(a,b,c) memset(a,b,sizeof(c)); //works only for 0 and -1
int main(){
  fast();
string s;
cin>>s;
vector<int> check(26,100);
fr(i,s.size())
{
  check[s[i]-'a']--;
}
fr(i,s.size()){
//  cout<<check[s[i]-'a']<<" ";
if(check[s[i]-'a']%2!=0){cout<<"No";return 0;}
}
cout<<"Yes";
 return 0;
  
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000

#define MI modint<MOD>
template<int mod>struct modint{
	int x;
	modint():x(0){}
	modint(LL n):x(n>=0?n%mod:(mod-(-n)%mod)%mod){}
	modint &operator+=(const modint &n){if((x+=n.x)>=mod)x-=mod;return *this;}
	modint &operator-=(const modint &n){if((x+=mod-n.x)>=mod)x-=mod;return *this;}
	modint &operator++(){*this+=1;return *this;}
  modint &operator--(){*this-=1;return *this;}
	modint &operator*=(const modint &n){x=(int)((LL)x*n.x%mod);return *this;}
	modint &operator/=(const modint &n){*this*=n.inv();return *this;}
	modint operator-()const{return modint(-x);}
	modint operator+(const modint &n)const{return modint(*this)+=n;}
	modint operator-(const modint &n)const{return modint(*this)-=n;}
	modint operator++(int){modint ret(*this);*this+=1;return ret;}
  modint operator--(int){modint ret(*this);*this-=1;return ret;}
	modint operator*(const modint &n)const{return modint(*this)*=n;}
	modint operator/(const modint &n)const{return modint(*this)/=n;}
	bool operator<(const modint &n)const{return x<n.x;}
	bool operator>(const modint &n)const{return x>n.x;}
	bool operator<=(const modint &n)const{return x<=n.x;}
	bool operator>=(const modint &n)const{return x>=n.x;}
	bool operator!=(const modint &n)const{return x!=n.x;}
	bool operator==(const modint &n)const{return x==n.x;}
	friend istream &operator>>(istream &is,modint &n){LL l;is>>l;n=modint<mod>(l);return is;}
	friend ostream &operator<<(ostream &os,const modint &n){return os<<n.x;}
	int getmod(){return mod;}
	modint inv()const{int a=x,b=mod,c=1,d=0,n;while(b){n=a/b;swap(a-=n*b,b);swap(c-=n*d,d);}return modint(c);}
	modint pow(LL n)const{modint ret(1),m(x);while(n){if(n&1)ret*=m;m*=m;n>>=1;}return ret;}
};

int main() {
	LL A;
  string N;
	MI m;
	cin>>N;
	A=N.size();
if(N.at(A-1)=='s'){
	cout<<N<<"es"<<endl;
}
else {
	cout<<N<<'s'<<endl;
}
}


Measured memory_bytes: 3528
#include <stdio.h>

int num;
int list[1000][4];
int limits[4];

int main(void) {
	int i;
	int found;
	while(1) {
		scanf("%d",&num);
		if(num==0)break;
		for(i=0;i<num;i++) {
			scanf("%d%d%d%d",
				&list[i][0],&list[i][1],
				&list[i][2],&list[i][3]
			);
		}
		scanf("%d%d%d%d",&limits[0],&limits[1],&limits[2],&limits[3]);
		for(i=0,found=0;i<num;i++) {
			if(list[i][1]<=limits[0] && list[i][2]<=limits[1] &&
					list[i][3]<=limits[2] &&
					(4*list[i][1]+9*list[i][2]+4*list[i][3])<=limits[3]) {
				found=1;
				printf("%d\n",list[i][0]);
			}
		}
		if(!found)puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int l,theta_in,theta = 90;
  double x = 0, y = 0;
  char k;
  double pi = atan(1)*4;
  while(cin >> l >> k >> theta_in,l||theta_in){
	x += l*cos(theta*pi/180); 
	y += l*sin(theta*pi/180);
	theta -= theta_in;
  }
  cout << (int) x << endl
	   << (int) y << endl;
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  char grid[h+2][w+2];
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> grid[i][j];
    }
  }

  int res[h+2][w+2];
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      res[i][j] = 0;
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (grid[i][j] == '#') {
        for (int dy = -1; dy < 2; dy++) {
          for (int dx = -1; dx < 2; dx++) {
            // cout << dy << " " << dx << endl;
            if (dy == 0 && dx == 0) continue;
            res[i+dy][j+dx]++;
          }
        }
      }
    }
  }

  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (grid[i][j] == '#') {
        cout << '#';
      } else {
        cout << res[i][j];
      }
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)

using namespace std;

int mx = INT32_MIN;
// vector<int> g[1000 * 100 + 1], a(1000 * 100 + 1, -1);

void dfs(int v, vector<int> g[], vector<int>& a) {
    int maxx = -1;
    for (auto i : g[v]) {
        if (a[i] == -1) {
            dfs(i, g, a);
        }
        if (a[i] > maxx) {
            maxx = a[i];
        }
    }
    a[v] = maxx + 1;
    if (a[v] > mx) {
        mx = a[v];
    }
}

int32_t main() {
    int v, e;
    cin >> v >> e;
    vector<int> g[v + 1], a(v + 1, -1);
    FOR(i, 0, e) { 
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
    }
    FOR(i, 1, v + 1) {
        if (a[i] == -1) {
            dfs(i, g, a);
        }
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 12740
import math
sum = 0
k = int(input())
for i in range(1,k+1):
  for j in range(1,k+1):
    if i <= j:
      for m in range(1,k+1):
        if j <= m:
          if i==j==m:
            l = math.gcd(i,j)
            sum += math.gcd(l,m)
          elif i==j or j==m or m==i:
            l = math.gcd(i,j)
            sum += 3*(math.gcd(l,m))
          else:
            l = math.gcd(i,j)
            sum += 6*(math.gcd(l,m))
print(sum)

Measured memory_bytes: 9220
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
	x = int(input())
	b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
	res = INF
	for S in [s[b - 1], s[b]]:
		for T in [t[d - 1], t[d]]:
			d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
			res = min(res, d1, d2)
	print(res)


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

int main(){

  int a, b, c, d, i, j, cnt=1, n;
  int s[100]={ }, r[100];

  cin >> n;

  for (i=0; i<n*(n-1)/2; i++){
    cin >> a >> b >> c >> d;
    if (c>d){
      s[a-1]+=3;
    } else if (c<d){
      s[b-1]+=3;
    } else {
      s[a-1]+=1; s[b-1]+=1;
    }
  }

  for (i=0; i<n; i++){
    for (j=0; j<n; j++){
      if (s[i]<s[j]) cnt++;
    }
    cout << cnt << endl;
    cnt=1;
  }

  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
using namespace std;
int countup_days(int m, int d) // m月d日が、1月1日から何日目か返す
{
    int         sum     = 0;
    const int   month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,};
    for (int i=1; i<m; i++) {
        sum += month[i];
    }
    return sum + d -1;
}
string what_day(int days) // 1/1からdays日後は何曜日か文字列を返す
{
    string day[]   = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    return day[days%7];
}
int main()
{
    int m, d;
    while (true) {
        cin >> m >> d;
        if (m==0 && d==0)
            break;
        cout << what_day(countup_days(m, d)) << endl;
    }
}

Measured memory_bytes: 1196
K,A,B = map(int,input().split(" "))

if (1+K) <= A:
    print(1+K)
    exit(0)

if B - A <= 2:
    print(1+K)
    exit(0)

K -= (A-1)
ans = A
ans += (B-A) * (K // 2)
if K % 2 == 1:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
    string n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n.size(); i++) {
        sum += n[i] - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A.at(i);

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        while (i + 1 < N && A.at(i) == A.at(i + 1))
            i++;

        if (i + 1 < N && A.at(i) < A.at(i + 1))
        {
            while (i + 1 < N && A.at(i) <= A.at(i + 1))
                i++;
        }
        else if (i + 1 < N && A.at(i) > A.at(i + 1))
        {
            while (i + 1 < N && A.at(i) >= A.at(i + 1))
                i++;
        }

        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B,K;
cin >> A >> B >> K;
vector<int> vec;
int a = max(A,B);
for (int i = 1;i <= a;i++) {
    if (A % i == 0 && B % i == 0) {
        vec.push_back(i);
    }
}
reverse(vec.begin(),vec.end());
cout << vec.at(K-1) << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
int main()
{
    int n,i,sum=0;
    char a[4];
    for(i=0;i<4;i++)
    {  scanf("%c",&a[i]);
       if(a[i]=='+')
         sum++;
       if(a[i]=='-')
          sum--;}
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
using System;

class sample
{
  static void Main()
  {
    int input = Convert.ToInt32(Console.ReadLine());
    
    int div = input/100;
    int mod = input%100;
    
    if(div*5<mod)
    {
      Console.WriteLine(0);
    }
    
    else
    {
      Console.WriteLine(1);
    }
  }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define N 500009
#define inf 1e18
//int mod=1e9+7;
int mod=998244353;
#define P pair<int,int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(),v.end()

#define ordered_set tree<P, null_type,less<P>, rb_tree_tag,tree_order_statistics_node_update> 

void end(int n=-1){
	cout<<n<<"\n";exit(0);
}
int n,k;
int a[N];
int dp[N];
int fun(int i){
	if(i>=n)return 0;
	if(dp[i]!=-1)return dp[i];
	int ans=inf;
	int f=0;
	for(int j=1;j<=k and i+j<n;j++){
		f=1;
		ans=min(ans,abs(a[i+j]-a[i])+fun(i+j));
	}
	if(!f)ans=0;
	return dp[i]=ans;
}

int32_t main(){
    AB_BHI_NI_DEGI
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<fun(0)<<"\n";
    return 0;
}

Measured memory_bytes: 14476
import numpy as np
import copy

a = map(int,raw_input().split())

def myfunc(a):
  a = np.array(a)
  if len(a[a % 2==0]) > 0:
    print 0
  else:
    m = np.max(a)
    a = np.delete(a, np.where(a==m)[0][0])
    print np.prod(a)

myfunc(a)

Measured memory_bytes: 10536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,M;cin>>N>>M;
    bool ok=true;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    for(int i=1;i<N;i++){
        ll a=A[i],b=A[0];
        int cnt1=0,cnt2=0;
        while(a%2==0){
            cnt1++;
            a/=2;
        }
        
        while(b%2==0){
            cnt2++;
            b/=2;
        }
        
        if(cnt1!=cnt2) ok=false;
    }
    
    ll m=1;
    for(int i=0;i<N;i++){
        m=m*(A[i]/2)/gcd(m,A[i]/2);
        if(m>M) ok=false;
    }
    
    if(!ok){
        cout<<0<<endl;
    }else{
        int ans=0;
        for(ll i=m;i<=M;i+=2*m){
            ans++;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 1024
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(6-a-b);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;



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

 for(ll i=-1001;i<1001;i++)
 {
  for(ll j=-1001;j<1001;j++)
  {
   if(pow(i,5)-pow(j,5)==n)
   {
    cout<<i<<" "<<j<<"\n";
   return 0;
   }
  }

 }



}


Measured memory_bytes: 4044
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ss;
#define int long long

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N,A,B;

ss main()
{
  cin>>N>>A>>B;
  cout<<min(A,B)<<" "<<max(0LL,A+B-N)<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

def calc(T):
    now = 0
    ret = 0
    for s in T:
        if s == '(':
            now += 1
        elif s == ')':
            now -= 1
        ret = min(ret, now)
    return ret

H = []
P = []
L = []

for s in S:
    less = -calc(s)
    if less == 0:
        H.append(s)
    else:
        l = s.count('(')
        r = len(s) - l
        if l >= r:
            P.append((less, s))
        else:
            L.append((less - (r - l), s))

P.sort(key=lambda a: a[0])
L.sort(key=lambda a: a[0], reverse=True)
P = [s for _, s in P]
L = [s for _, s in L]
ans = ''.join(H) + ''.join(P) + ''.join(L)

l = ans.count('(')
r = len(ans) - l

if l != r or calc(ans) < 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 63992
h, w = map(int, input().split(" "))

mode = 'odd'
if w%2 == 0:
    mode = 'even'
    
    
v = 0
if mode == 'odd':
    v1 = (w-1) // 2 + 1
    
    if h%2 == 0:
        v = (2*v1 -1) * (h//2)
    else:
        v = v1 + ((2*v1 -1) * (h//2))
else:
    v1 = w // 2
    v = v1 * h

if (h ==1) or (w == 1):
    v = 1
        
print(v)  

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

using namespace std;

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

    int n, k;
    double ans = 0;
    cin >> n >> k;

    for (int i = 1; i <= n; i++)
    {
        if (i >= k)
            ans += 1.0 / (double)n;
        else
            ans += 1.0 / (double)n * pow(0.5, ceil(log2((double)k / (double)i)));
    }
    cout << fixed << setprecision(12) << ans << '\n';

    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> pref(k+1), dp(k+1);
  dp[0] = 1;
  for(int kid = 1;kid<=n;kid++){
    int c;
    cin >> c;
    pref[0] = dp[0];
    for(int i=1; i<=k; ++i) {
      pref[i] = (pref[i-1] + dp[i]) % MOD;
      dp[i] = (pref[i] - (i-c>=0 ? pref[i-c-1] : 0)) % MOD;
    }
  }

  int ans = dp[k];
  if(ans < 0) ans += MOD; 
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),c=sc.nextInt(),k=sc.nextInt();
        int[] t=new int[n];
        for (int i = 0; i < n; i++) {
            t[i]=sc.nextInt();
        }
        Arrays.sort(t);
        int ans=0,tmp=0,pas=0;
        for (int i = 0; i < n; i++) {
            if(i==0){
                ans++;
                tmp=t[i];
                pas++;
            }else{
                if(tmp+k>=t[i]&&pas<c){
                    pas++;
                }else{
                    pas=1;
                    ans++;
                    tmp=t[i];
                }
            }
        }
        out.println(ans);
    }
}

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

ll count_factors(int n)
{
    int ans = 0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            if(n/i == i)
                ans += 1;
            else
                ans += 2;
        }
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    ll ans =0;
    for(int i=1;i<=n-1;i++)
    {
        int x = n-i;
        ans += count_factors(x);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3548
<?php
list($s) = fscanf(STDIN,'%s');
$n = strlen($s);

$array0 = array();
$array1 = array();
$count0 = $count1 = 0;

for($i=0;$i<$n;$i++){
    if($i%2==0){
        $array0[$i]=0;
        $array1[$i]=1;
    }else{
        $array0[$i]=1;
        $array1[$i]=0;
    }
    if($s[$i]==$array0[$i]) $count0++;
    if($s[$i]==$array1[$i]) $count1++;
}

echo min($count0,$count1);



Measured memory_bytes: 14840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();

		if (A1 + A2 + A3 >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}

		sc.close();
	}

}


Measured memory_bytes: 21972
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

#include <set>
void solve() {
  int n;
  cin >> n;
  cout << n*n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d;
  long long maxi=-LLONG_MAX;
  cin >> a >> b >> c >> d;
  maxi=max(maxi,a*c);
  maxi=max(maxi,b*d);
  maxi=max(maxi,a*d);
  maxi=max(maxi,b*c);
  cout << maxi;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    string s;
    cin >> s;
    
    ll N = s.size();
    vector<vector<ll>> dp(N+10,vector<ll>(13,0));
    
    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        ll num;
        num = (s[i]=='?' ? -1 : s[i]-'0');
        for(int k=0;k<13;k++){
            for(int j=0;j<10;j++){
                if(num!=-1 && num!=j) continue;
                dp[i+1][(k*10+j)%13] += dp[i][k];
                dp[i+1][(k*10+j)%13] %= MOD;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define read(x)  freopen("input.txt","r",stdin);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
using namespace std;
map<char,ll>m;
int main(){//read(x);
//fast;
ll a,b,c,d,e,f,g,h,i,j,k,l=0,n,t;
string s;
cin>>s;
n=s.size();
for(i=0;i<n;i++){
    m[s[i]]++;
}
for(auto i:m){
    b=i.S;
    char aa=i.F;
    if(b&1){
        l++;
        break;
    }
}
if(l==0)cout<<"Yes\n";
else cout<<"No\n";

}














Measured memory_bytes: 3624
h, w = map(int, input().split())

even_rows = h // 2
odd_rows = (h+1) // 2

if w > 1 and h > 1:
    ans = 0
    ans += w // 2 * even_rows
    ans += (w+1) // 2 * odd_rows

    print(ans)
else:
    print(1)

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

int main() {
  int N, k = 1;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  for (int j = 0; j < N; j++) {
    k = s.at(k - 1);
    if (k == 2) {
      cout << j + 1 << endl;
      break;
    }
    else if (j == N -1) {
      cout << -1 << endl;
    }
  }

}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int n, x;
    while(cin >> n >> x, n | x) {
        int res = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i + 1; j <= n; j++) {
                for(int k = j + 1; k <= n; k++) {
                    if(i + j + k == x)
                        res++;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
L,R = map(int,input().split())
f = 0
if R-L >= 2019:
    f = 1
L %= 2019
R %= 2019
m = 2018
if f == 1:
    for i in range(0,2018):
        for j in range(i+1,2019):
            r = (i*j)%2019
            if r < m:
                m = r
elif L < R:
    for i in range(L,R):
        for j in range(i+1,R+1):
            r = (i*j)%2019
            if r < m:
                m = r
else:
    for i in range(0,R):
        for j in range(i+1,R+1):
            r = (i*j)%2019
            if r < m:
                m = r
    for i in range(0,R+1):
        for j in range(L,2019):
            r = (i*j)%2019
            if r < m:
                m = r
    for i in range(L,2018):
        for j in range(i+1,2019):
            r = (i*j)%2019
            if r < m:
                m = r
print(m)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N,t;
vector<int> p, out;
int main() {
	bool flag = false;
	int count = 0, temp = 0;
	scanf("%d", &N);
	rep(i, 0, N) {
		scanf("%d", &t), p.push_back(t);
		if (t == i + 1) {
			temp++;
			flag = true;
			out.push_back(t);
		}
		else {
			if (flag) {
				count += (temp + 1) / 2;
			}
			flag = false, temp = 0;
		}
	}
	if (flag) {
		count += (temp + 1) / 2;
	}
	flag = false;
	printf("%d", count);
	return 0;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define cfM 998244353;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;
    int a , b , c , d;
    cin>>a>>b>>c>>d;
    int g=ceil(a/float(d));
    int f=ceil(c/float(b));
    if(g>=f)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3612
using Kujikatsu001.Questions;
using Kujikatsu001.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Kujikatsu001.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc073/tasks/abc073_b
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var count = 0;

            for (int i = 0; i < n; i++)
            {
                var lr = inputStream.ReadIntArray();
                count += lr[1] - lr[0] + 1;
            }

            yield return count;
        }
    }
}


namespace Kujikatsu001
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu001.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu001.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396