akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vii r(n), b(n);
	rep(i, n) cin >> r[i].first >> r[i].second;
	rep(i, n) cin >> b[i].first >> b[i].second;

	auto cmp = [](pair<int, int> r, pair<int, int> l) { return r.second > l.second; };
	sort(ASC(r), cmp);
	sort(ASC(b));

	map<pair<int, int>, bool> check;

	int ans = 0;

	rep(i, n) {
		rep(j, n) {
			if (b[i].first > r[j].first && b[i].second > r[j].second && check[r[j]] == false) {
				check[r[j]] = true;
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N, L = list(map(int, input().split()))
T = []
for i in range (1, N+1): 
	T.append(L+i-1)
if T[0] * T[-1] <= 0:
    print(sum(T))
else:
    if min(T) < 0:
        print(sum(T) - T[-1])
    else:
        print(sum(T) - T[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    string s,t;cin >> s >>t;
    string m;
    for(int i = 0; i < n; i++) {
        bool x=true;
        string y;
        for(int j = i; j < n; j++) {
            if(s[j]==t[j-i]) y += s[j];
            else{
                x=false;
                break;
            }
        }
        if(x){
            m=y;
            break;
        }
    }

    cout << 2*n-m.size() << endl;
    

    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int max = 0;
		for(int i = 0;i < S.length()/2-1;i++) {
			String key = S.substring(0,i+1);
			if(key.equals(S.substring(i+1, 2*i+2))) {
				max = 2 * key.length();
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int x=h1*60+m1;
  int y=h2*60+m2;

  cout<<(y-x)-k<<newl;
  return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

R, D, X = get_ints

dx = X

10.times do
  dx = R * dx - D
  puts dx
end


Measured memory_bytes: 14456
#include <cstdio>
int main(int argc , char** argv)
{
	int num = 0;
	scanf("%d",&num);
	int maxCnt = 1 , maxCnt_Number = 1;
	for(int i=2;i<=num;i++){
		int cnt = 0;
		int n = i;
		while(1){
			if (n%2 != 0){break;}
			n/=2;
			cnt++;
		}
		if (maxCnt <= cnt){
			maxCnt = cnt;
			maxCnt_Number = i;
		}
	}
	printf("%d\n",maxCnt_Number);
	return 0;
}

Measured memory_bytes: 128
a,b = gets.chomp.split(" ").map(&:to_i)
answer = ""
if a != b then
  if a < b then
    for i in 1..b do
      answer += a.to_s
    end
  else
    for i in 1..a do
      answer += b.to_s
    end
  end
else
    for i in 1..a do
      answer += a.to_s
	end
end
print answer

Measured memory_bytes: 1788
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();    
    println!("{}", if (a + b) % 2 == 0 { ((a + b) / 2).to_string() } else { "IMPOSSIBLE".to_string()});
}


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

int main(){
	int n,m; cin>>n>>m;
	int a,b;
	vector <int> samp;
	vector <vector<int> > v(n+1,samp);
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<bool> visited(n,false);
	queue <int> level;
	level.push(1);
	visited[1] = true;
	int si=0;
	int le=0;
	vector<int> res(n+1);
	while(!level.empty()){
		si = level.size();
		while(si--){
			int x = level.front();
			level.pop();
			int c = v[x].size();
			for(int j=0;j<c;j++){
				if(!visited[v[x][j]]){
					visited[v[x][j]] = true;
					level.push(v[x][j]);
					res[v[x][j]] = x;
				}
			}
		}
		le++;
	}
	cout << "Yes" << endl;
	for(int i=2;i<n+1;i++){
		cout << res[i] << endl;
	}
	
}

Measured memory_bytes: 10016
// セグメント木(区間の最小値を求めるRMQ用)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long long

long long SEG_MAX = 2147483647;

template<typename T>
class SegmentTreeRMQ {
  int n;
  vector<T> dat;
public:
  // 数列を渡す。
  SegmentTreeRMQ(vector<T> v) {
    int size = v.size();
    n = 1;
    while (n < size) n *= 2;
    dat.resize(2 * n -1, SEG_MAX);

    for (int i = 0; i < size; ++i) dat[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]); 
  }

  T getElements() {
    return n;
  }

  void update(int x, T val) {
    x += n - 1;
    dat[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      dat[x] = min (dat[2 * x + 1], dat[2 * x + 2]);
    }
  }

  // [a, b), k: 節点, [l,r) rはセグメント木の要素数 (n * 2 - 1);
  int find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a or b <= l) return SEG_MAX;
    if (a <= l and r <= b) return dat[k];

    T vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
    T vr = find(a, b, 2 * k + 2, (l + r) / 2, r);

    return min(vl, vr);
  }
};

int main() {
  ll n,q;
  cin >> n >> q;

  SegmentTreeRMQ<long long> seg(vector<long long>(n, SEG_MAX));

  for (int i = 0; i < q; ++i) {
    long long c,x,y;
    cin >> c >> x >> y;
    if (c == 0) seg.update(x,y);
    else cout << seg.find(x,y+1,0,0,seg.getElements()) << endl;
  }


  // cout << ((0 < 0) ? "ok" : "ng") << endl;
}


Measured memory_bytes: 5648
package main

import(
    "fmt"
)



func main() {
    var x,t int
    fmt.Scan(&x,&t)
    ans := max32(x-t,0)
    fmt.Println(ans)
}





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

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

const int PINF = 1000*1000*1000;

int main()
{
  int n, k;
  cin >> n >> k;
  int h[n];
  for (int i = 0; i < n; ++i)
    cin >> h[i];
  int dp[n];
  for (int i = 0; i < n; ++i)
    dp[i] = PINF;
  dp[0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 1; j <= k; ++j)
      if (i+j < n)
	dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
  cout << dp[n-1] << '\n';
}


Measured memory_bytes: 1024
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    res = 0

    c = [[0 for i in range(10)] for j in range(10)]

    for k in range(1,N+1):
        s = str(k)
        fd = int(s[0])
        ld = int(s[-1])
        c[fd][ld] += 1

    for i in range(10):
        for j in range(10):
            res += c[i][j] * c[j][i]

    print(res)



main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pl pair<ll,ll>
#define plp pair<ll,pl>
#define ppl pair<pl,ll>
#define pb push_back
#define pi acos(-1.0)
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define vl vector<ll>
#define mp make_pair
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define vll vector<vector<ll>>
#define all(a) a.begin(),a.end()
#define INF 1e9+5
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
 
 //ll n,m;
ll MOD1=1000000007;
ll MOD2=998244353;
 
 
void yes() {cout<<"YES"<<endl;}
void no() {cout<<"NO"<<endl; }
/*
ll gcd(ll a,ll b);
ll lcm(ll a, ll b);
ll mod_exp(ll x,ll power,ll m);
ll ext_gcd(ll a,ll b,ll& x,ll& y);
void swap(ll& a,ll& b);
ll root(vector<ll>& arr,ll a);
void Union(vector<ll>& arr,ll a,ll b);
const ll N=32001;
vl fenwick(N,0);
void update(ll index,ll add);
ll sum(ll index);
ll find_kth_smalest(ll k);
ll find(ll k);
ll ETF(ll n);
*/
 
 
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    return gcd(b%a, a);
}
 
ll lcm(ll a, ll b)
{
    return ( a*b/(gcd(a,b)));
}
 
//void sieve();
//vector<ll> factorise(1000+2,-1);
//vector<ll> prime(20005,1);
//vl fug;
//void p();
//void fact();
 
 
/*
void sieve()
{
    prime[0]=prime[1]=0;
    for(ll i=2;i<=sqrt(2005);i++)
    {
        if(prime[i]==1)
        {
            for(ll j=i*i;j<2005;j+=i)
                prime[j]=0;
        }
    }
}
*/





void solve()
{
  
    ll n,w; cin>>n>>w;
    ll temp=n;
    vl value,weight;
    
    while (temp--) {
        ll wt,val;
        cin>>wt>>val;
        value.eb(val); weight.eb(wt);
    }
    
    ll dp[n+1][w+1];
    
    for(ll i=0;i<=w;i++)
        dp[0][i]=0;
    
    for(ll i=0;i<=n;i++)
           dp[i][0]=0;
    
    
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if(weight[i-1]<=j)
                dp[i][j]=max(value[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    
    cout<<dp[n][w]<<endl;
    
    
    
    
    
    
    
 
    
}
 
int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll tests=1;
    //cin>>tests;
    while (tests--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 82480
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

int main(void){
  int n,l,r;
  ll res=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>l>>r;
    res+=r-l+1;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    int H, W;
    cin >> H >> W;
    
    vector<string> A(H);
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }
    
    vector<bool> row(H, false);
    vector<bool> col(W, false);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }
    
    for (int i = 0; i < H; i++) {
        if (row[i]) {
            for (int j = 0; j < W; j++) {
                if (col[j]) {
                    cout << A[i][j];
                }
            }
            cout << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
if [a1, b1, a2, b2, a3, b3].count(1) == 3 or [a1, b1, a2, b2, a3, b3].count(2) == 3 or [a1, b1, a2, b2, a3, b3].count(3) == 3 or [a1, b1, a2, b2, a3, b3].count(4) == 3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
#include<iostream>
#include<complex>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef complex<double> P;
#define eps 0

//~ÌSÀWða,b,¼aðr1,r2Æ·éB
//r1Ær2ÌÔÌ£ðßÄ]·èÉæèr1Æ»ÌÓÌÈ·pðßéB
// ÆÍpolarðgÁÄÀWð¶¬·éB
//ñ_ÌÀWðÔ·B
pair<double,double> CC_intersection(P a,P b,double r1,double r2){//~Æ~Ìð_
  double r3 = abs(a-b);
  double theta = acos( (r1*r1 + r3*r3 -r2*r2)/(2*r1*r3) ); 
  return make_pair(theta+arg(b-a),arg(b-a)-theta);
}

bool cmp(const P &a,const P&b){
  return arg(a)<arg(b);
}
class Circle{
public:
  vector<double> data;
};

double solve(int n,P *in,double *r){
  Circle data[n];
  double ret =0;
  rep(i,n){ 
    //data[i].data.push_back(asin(1));data[i].data.push_back(asin(-1));
    data[i].data.push_back(0);data[i].data.push_back(0.1);
    rep(j,n){
      if ( i==j)continue;
      if ( r[i]+r[j] <eps+abs(in[i]-in[j]))continue;
      if ( abs(in[i]-in[j])+r[i] <r[j]+eps||abs(in[i]-in[j])+r[j]<r[i]+eps)continue;
      
      pair<double,double> a=CC_intersection(in[i],in[j],r[i],r[j]);
      data[i].data.push_back(a.first);
      data[i].data.push_back(a.second);
    }
  }
  
  rep(i,n)sort(data[i].data.begin(),data[i].data.end());
  


  rep(i,n){
    int size=data[i].data.size();
    rep(j,size){
      double now = data[i].data[j],nex=data[i].data[(j+1)%size];
      
      double theta = (nex-now)/2+now;
      if (nex-now<0)theta=(acos(-1)*2+nex-now)/2+now;
      
      P mid = polar(r[i],theta)+in[i];
      
      bool flag=true;
      rep(k,n){
	if ( i == k)continue;
	if (abs(in[k]-mid)<eps+r[k]){flag=false;break;}
      }

      double test =nex-now;
      if ( test <0)test=acos(-1)*2+nex-now;
      if ( flag){
	ret+=r[i]*abs(test);
      }
      
    }
  }
  return ret;
}

main(){
  int n;
  while(cin>>n&&n){
    P in[n];double r[n];
    rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i];
    printf("%.10lf\n",solve(n,in,r));
  }
  return false;
}

Measured memory_bytes: 0
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N = intinput()
    datas = list(mulinputs())
    bucket = [0] * N
    for data in datas:
        bucket[data-1] += 1

    # 出力
    for b in bucket:
        print(b)



Measured memory_bytes: 33816
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    long double p[n+1];
    for (int i = 1; i < n+1; ++i)
    {
        cin>>p[i];
    }

    cout<<setprecision(20);
    long double dp[n+1][n+1];
    for (int i = 0; i < n+1; ++i)
    {
        for (int j = 0; j < n+1; ++j)
        {
            dp[i][j]=0.0;
        }
    }

    dp[0][0]=1.0;
    for (int i = 1; i < n+1; ++i)
    {
        dp[0][i]=dp[0][i-1]*(1-p[i]);
    }

    for (int i = 1; i < n+1; ++i)
    {
        for (int j = i; j < n+1; ++j)
        {
            dp[i][j] = (dp[i][j-1]*(1-p[j])) + (dp[i-1][j-1]*p[j]);
        }
    }

    long double ans=0.0;
    for (int i = (n/2)+1; i<=n; ++i)
    {
        ans += dp[i][n];
    }
    cout<<ans;

    return 0;
}


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

#pragma warning(disable : 4996)

#define INF (1 << 25)

using namespace std;

int main()
{
	int N;

	scanf("%d", &N);

	vector<int> D(N - 1);

	for (int i = 0; i < N - 1; i++)
	{
		scanf("%d", &D[i]);
	}

	vector<vector<vector<int> > > dp(2, vector<vector<int> >(N / 2 + 1, vector<int>(2, INF)));

	dp[0][0][0] = 0;

	for (int i = 1; i < N; i++)
	{
		for (int j = 0; j <= N / 2; j++)
		{
			dp[i % 2][j][0] = min(dp[(i - 1) % 2][j][0], dp[(i - 1) % 2][j][1] + D[i - 1]);
			
			if (j != 0)
			{
				dp[i % 2][j][1] = min(dp[(i - 1) % 2][j - 1][1], dp[(i - 1) % 2][j - 1][0] + D[i - 1]);
			}
		}
	}

	printf("%d\n", min(dp[1][N / 2][0], dp[1][N / 2][1]));

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl b(n+1);
  b[0] = INF;
  b[n] = INF;
  rep(i,n-1) cin >> b[i+1];
  ll ans=0;
  rep(i,n){
    ans += min(b[i],b[i+1]);
  }
  cout << ans;
 return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans1 = a * c;
  ll ans2 = a * d;
  ll ans3 = b * c;
  ll ans4 = b * d;
  cout << max(ans1, max(ans2, max(ans3, ans4))) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

vector<int> prime;
bool is_prime[55558];

int sieve(int n){
    int p=0;
    REP(i,n+1)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,n+1){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}

int main(){
    int n;
    cin >> n;
    sieve(55555);
    int cnt = 0;
    REP(i, prime.size()){
        if(prime[i] % 5 == 1){
            print(prime[i] << " ");
            cnt++;
            if(cnt == n)break;
        }
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main() {
	int a, k, b;
	cin >> a>> b>> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1)a--;
			b += a / 2;
			a /= 2;
		}
		if (i % 2 == 1) {
			if (b % 2 == 1)b--;
			a += b / 2;
			b /= 2;
		}

	}
	cout << a << " " << b;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> s = nextCharArray();
      int output = 0;
      for(int i = 0; i < s.size(); i++){
        if(s.get(i).equals("1")){
          output++;
        }
      }
      myout(output);
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 33164
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  long long n;
  int m;
  cin>>n>>m;
  
  int a[m];
  int b[m];
  REP(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  
  long long all_pairs = n*(n-1)/2;
  long long ans[m];
  UnionFind uni(n);
  ans[m-1]=all_pairs;
  for(int i=m-1;i>=0;i--){
    if(i==m-1)continue;
    if(uni.root(a[i+1])==uni.root(b[i+1])){
      ans[i]=ans[i+1];
    }else{
      ans[i] = ans[i+1]-(long long)uni.size(a[i+1])*(long long)uni.size(b[i+1]);
    }
    uni.connect(a[i+1],b[i+1]);
  }
  REP(i,m){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()

int main(){
	string a,b,c,d; cin>>a>>b>>c>>d;
	string s=a+b+c+d;
	sort(all(s));
	if(s=="1479") cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

int main() {
  double a,b,x,p=3.141592653589;
  cin>>a>>b>>x;
  double v=a*a*b,TAN;
  if(x<=v/2) TAN = a*b*b/(2*x);
  else TAN = 2*(a*a*b-x)/(a*a*a);
  cout<<setprecision(12)<<atan(TAN)*180/p;
}

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

#define ll long long
#define rep(i, n) for(ll i = 0; i <= n; i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
   ll A,B,C,D,E,F;
   cin >> A >> B >> C >> D >> E >> F;
   double maxwoter = (F / (100 + E))*100;
   //cout << maxwoter <<endl;
   ll a = maxwoter/(100*A);
   ll b = maxwoter/(100*B);
   //cout << a << b <<endl;
   double density = -1;
   ll all = 0;
   ll small = 0;
   
   for(int i = 0;100*A*i <= F;i++){
       for(int j = 0;100*A*i+100*B*j <= F;j++){
           if(100*A*i+100*B*j <= F){
               ll maxsuger = (A*i+B*j)*E;
               for (int k = 0;k*C <= maxsuger;k++){
                   for(int l = 0;k*C+l*D <= maxsuger;l++){
                       if(100*A*i+100*B*j+k*C+l*D != 0 && 100*A*i+100*B*j+k*C+l*D <= F){
                            double newdensity = 1. * 100*(k*C+l*D)/(100*A*i+100*B*j+k*C+l*D);
                            if(newdensity>density){
                                all = 100*A*i+100*B*j+k*C+l*D;
                                small = k*C+l*D;
                                density = newdensity;
                             }
                       }
                   }
               }
           }
       }
   }
   cout << all << " "<< small <<endl;
   
}


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

using namespace std;
int main(){
  int n,i,j;
  int w;
  string str;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> str;
    vector <int> s;
    for(j=0;j<str.length();j++){
      s.push_back(str[j]-'0');
    }
    w=0;
    while(s.size()>1){

      int b = (s[0]+s[1])/10;
      s[1]=(s[0]+s[1])%10;
      if(b==0)s.erase(s.begin());
      else s[0]=1;
      /*for(int k=0;k<s.size();k++)cout<<s[k]<<" ";
      cout<<endl;*/
      w++;
    }
    if(w%2==0) printf("Audrey wins.\n");
    else printf("Fabre wins.\n");
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S,T;
  cin>>S;
  cin>>T;
  int count=0;
  for(int i=0;i<S.length();i++){
    if(S[i]!=T[i]){
      S[i]=T[i];
      count++;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int H,W;
ll mod = 1e9+7;
char maze[1010][1010];
ll dp[1010][1010];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> maze[i];
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '#') continue;
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
            dp[i][j+1] += dp[i][j];
            dp[i][j+1] %= mod;
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;
const int sz=200000;
int fact[sz],ifact[sz],inv[sz];

map<int,int> prime_factor(int n){
    map<int,int> res;
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            res[i]++;
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

void make(){
    inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1;
    for(int i=2;i<sz;i++){
        inv[i]=inv[mod%i]*(mod-mod/i)%mod;
        fact[i]=fact[i-1]*i%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
    }
}

int comb(int n,int k){
    if(n<k) return 0;
    return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
}

signed main()
{
    int N,M; cin>>N>>M;
    
    map<int,int> cnt=prime_factor(M);
    make();
    
    int ans=1;
    for(auto p:cnt){
        ans*=comb(p.second+N-1,N-1);
        ans%=mod;
    }
    cout<<ans<<endl;

}

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

int main() {
	int A, B, r = 0;
	cin >> A >> B;
	++B;
	for (; A < B; ++A) {
		if (A / 10000 == A % 10 && A / 1000 % 10 == A / 10 % 10)
			++r;
	}
	cout << r;
}

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

int main() {
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()) {cout << "GREATER" << endl; return 0;}
    if(a.size() < b.size()) {cout << "LESS" << endl; return 0;}
    if(a>b) {cout << "GREATER" << endl; return 0;}
    if(b>a) {cout << "LESS" << endl; return 0;}
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
const int64_t maxValue = 1000 * 1000 * 1000;

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

  vector<int> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];

  vector<int64_t> cost(n);
  cost[0] = 0;

  for (int i = 1; i < n; i++) {
    int64_t min_cost = maxValue;
    int start = max(0, i - k);
    for (int j = start; j < i; j++) {
      if ((cost[j] + abs(h[j] - h[i])) < min_cost) {
        min_cost = cost[j] + abs(h[j] - h[i]);
      }
    }
    cost[i] = min_cost;
  }

  cout << cost[n - 1] << "\n";
  return 0;
}


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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

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

  ll m, k;
  cin >> m >> k;

  if(k > ((1 << m) - 1)){
    cout << -1 << endl;
    return 0;
  }
  if(m == 0){
    if(k == 0){
      cout << 0 << " " << 0 << endl;
    }else{
      cout << -1 << endl;
    }
    return 0;
  }
  if(m == 1){
    if(k == 0){
      cout << "0 0 1 1" << endl;
    }else{
      cout << -1 << endl;
    }
    return 0;
  }

  vector < ll > v;
  for(int i = 0;i < (1 << m); i++){
    if(i == k) continue;
    v.push_back(i);
    cout << i << " ";
  }

  cout << k << " ";
  reverse(v.begin(), v.end());
  for(auto i : v) cout << i << " ";
  cout << k << " ";
  cout << endl;
}


Measured memory_bytes: 2932
import bisect
import math

def prime(n):
    for j in range(2, int(math.sqrt(n) + 1)):
        if n % j == 0:
            return False
    return True

lis = []
for i in range(3, 100000, 2):
    if prime(i) and prime((i + 1) / 2):
        lis.append(i)

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    left_ind = bisect.bisect_left(lis, l)
    right_ind = bisect.bisect_right(lis, r)
    print(right_ind - left_ind)

Measured memory_bytes: 3444
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int x;cin>>x;
  if (x==3 || x==5 || x==7) {
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << H*W - W*h - H*w +w*h << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n;
    cin>>a>>b>>c;
    n=a*100+b*10+c;
    if(n%4==0)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
	return 0;
}


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

int main(void){
    long long int a, b, c, i, j, min, ans=0;
    char s[5], t[5];
    scanf("%lld %lld", &a, &b);
    while(b>1){
        b = b - (a-1);
        ans++;
    }
    printf("%lld", ans);
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll n;
    cin>>n;
    set<int> s;

    vector<ll> a(1<<n);
    for(i=0;i<(1<<n);i++) cin>>a[i];

    vector<ll> z(1<<n,0);
    for(i=(1<<n)-1;i>=0;i--){
        if(i==(1<<n)-1) {
            if(a[i]==1) z[i]=1;
        }
        else {
            bool fl=1;
            for(j=0;j<n;j++){
                int r=i|(1<<j);
                if(r==i) continue;
                if(z[r]==0) fl=0;
            }
            if(fl&&a[i]==1) z[i]=1;
        }
    }

    vector<bool> attained(1<<n,0);
    int ans=0;
    
    for(i=0;i<(1<<n);i++){
        if(a[i]==1||attained[i]==1){
            if(a[i]==1&&attained[i]==0) ans++;
            for(j=0;j<n;j++){
                int r=i|(1<<j);
                if(r==i) continue;
                if(z[r]==0){
                    cout<<-1<<endl;
                    return 0;
                }
                else attained[r]=1;
            }
        }
    }

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


Measured memory_bytes: 19440
#include <iostream>

using namespace std;

int main(void){
   
    int a, b;
    int c;
    cin >> a >> b;
    
    a *= 10;
    if(b >= 10)
        a *= 10;
    if(b >= 100)
        a *= 10;
    a += b;
    
    for(int i = 0; i < 330; i++){
        if(i * i == a){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long    ←保留
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
//C++(GCC9.2.1)

/*signed*/int main() {
    //宣言
    long long n;
    cin >> n;
    long long x, y;
    x = y = 0;
    long long c;
    c = 0;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        int t, a, b;
        cin >> t >> a >> b;
        if (abs(x - a) + abs(y - b) > t - c) {
            flag = false;
        }
        else if (abs(x - a) + abs(y - b) < t - c) {
            if ((abs(x - a) + abs(y - b)) % 2 != 0) {
                if (t - c % 2 == 0) flag = false;
            }
            else {
                if (t - c % 2 != 0) flag = false;
            }
        }
        x = a;
        y = b;
        c = t;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define rep(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long ll;

int main(){
    ll n, q;
    cin >> n >> q;

    ll query, k, d = 0LL;
    rep(q){
        cin >> query >> k;

        if(query == 0LL){
            cout << (k-1+d)%n + 1LL << endl;
        }else{
            d += k;
        }
    }

    return 0;
}



Measured memory_bytes: 3088
import java.util.*;

public class Main {

    private static final long MOD = 1_000_000_007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            sum += A[i];
        }
        long[] prefSum = new long[N];
        prefSum[0] = A[0];
        for (int i = 1; i < N; i++) {
            prefSum[i] = prefSum[i-1] + A[i];
        }

        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += (((sum-prefSum[i])%MOD)*A[i])%MOD;
            ans %= MOD;
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 60396
while true
ary = gets.split
a = ary[0].to_i
op = ary[1].to_s
b = ary[2].to_i
    case
    when op == "+"
        puts a + b
    when op == "-"
        puts a - b
    when op == "*"
        puts a * b
    when op == "/"
        if b == 0
            break
        else
            puts a / b
        end
    when op == "?"
        break
    end
end


Measured memory_bytes: 6868
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
	
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

#define MAX 1000000

struct POS{int x,y;} pos;

int w, h, n;

bool rot(string cmd,char *dir){
	if(cmd=="LEFT"){
		switch(*dir){
			case 'u':*dir='l';break;
			case 'l':*dir='d';break;
			case 'd':*dir='r';break;
			case 'r':*dir='u';break;
		}
		return true;
	}else if(cmd=="RIGHT"){
		switch(*dir){
			case 'u':*dir='r';break;
			case 'r':*dir='d';break;
			case 'd':*dir='l';break;
			case 'l':*dir='u';break;
		}
		return true;
	}
	return false;
}

void go(string cmd,char *dir,int n){
	if(cmd=="FORWARD"){
		switch(*dir){
			case 'u':
				
				pos.y+=n;break;
			case 'r':pos.x+=n;break;
			case 'd':pos.y-=n;break;
			case 'l':pos.x-=n;break;
		}
	}else if(cmd=="BACKWARD"){
		switch(*dir){
			case 'u':pos.y-=n;break;
			case 'r':pos.x-=n;break;
			case 'd':pos.y+=n;break;
			case 'l':pos.x+=n;break;
		}
	}
}

int main(){
	string cmd;
	char dir;
	
	while(cin>>w>>h,h||w){
		pos.x=1;pos.y=1;
		dir='u';
		while(1){
			cin>>cmd;
			if(cmd=="STOP"){
				cout<<pos.x<<" "<<pos.y<<endl;
				break;
			}
			if(rot(cmd,&dir)){
				continue;
			}else{
				cin>>n;
				go(cmd,&dir,n);
			}
			if(pos.x<1) pos.x=1;
			if(pos.y<1) pos.y=1;
			if(pos.x>w) pos.x=w;
			if(pos.y>h) pos.y=h;
		}
	}
}

Measured memory_bytes: 1216
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n;
LL ans;

struct A {LL x, y;} a[MAXN];

bool CMP(A x, A y)
{
    return x.x+x.y>y.y+y.x;
}

int main()
{
    scanf("%d", &n);
    for(rint i=1; i<=n; ++i)
    {
        scanf("%lld%lld", &a[i].x, &a[i].y);
    }
    sort(a+1, a+n+1, CMP);
    for(rint i=1; i<=n; ++i)
    {
        if(i&1) ans+=a[i].x;
        else ans-=a[i].y;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1664