akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long double
#define pb push_back
#define sz size
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define F first
#define S second
#define ld long double
#define ll long long
#define pb push_back
#define sz size
using namespace std;
const int N=500+10;
ll n,k,ans=1,a[N],pr_a[N],pr_b[N],sum;
bool ch(ll mod){
loop(i,1,n){pr_a[i]=a[i]%mod;}
sort(pr_a+1,pr_a+1+n);
loop(i,1,n){pr_b[i]=pr_b[i-1]+(mod-(pr_a[i]%mod));pr_a[i]+=pr_a[i-1];}
loop(i,1,n){
	ll sf=pr_b[n]-pr_b[i];
	ll pr=pr_a[i];
	//cerr<<pr<<" "<<sf<<endl;
	if(pr==sf && pr<=k){return 1;}
}	
return 0;	
}
int main(){
scll(n);scll(k);
loop(i,1,n){scll(a[i]);sum+=a[i];}
for(ll i=1;i*i<=sum;i++){
	if(sum%i==0){
	    if(ch(i)){ans=max(ans,i);}
	    if(ch(sum/i)){ans=max(ans,sum/i);}
	}
}
printf("%lld\n",ans);
}
/**
 3 1 2 1
 1 1 2 3
 * */

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

int main(){
    int n,m,l;
    cin>>n>>m>>l;
    int a[n][m],b[m][l];
    long int c[n][l];
    /*Input a,b & Initialize c*/
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            c[i][j]=0;
        }
    }
    
    /*calculate*/
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    
    /*Output*/
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j!=l-1) cout<<c[i][j]<<" "<<flush;
            else cout<<c[i][j]<<endl;
        }
    }
    
}


Measured memory_bytes: 3220
void main() {
	auto ip = readAs!(int[]);
	N = ip[0], W = ip[1];
	
	dp = new int[][](N+1, W+1);
	foreach(ref i; dp) i[] = -1;
	
	foreach(_; 0..N) {
		auto ip2 = readAs!(int[]), a = ip2[0], b = ip2[1];
		v ~= a; w ~= b;
	}
	
	calc(0, W).writeln;
}

int N, W;
int calc(int i, int j) {
	debug writefln("%d, %d", i, j);
	if(dp[i][j] >= 0) return dp[i][j];
	
	if(i == N) return 0;
	if(j < w[i]) return dp[i][j] = calc(i + 1, j);
	return dp[i][j] = max(calc(i + 1, j), calc(i + 1, j - w[i]) + v[i]);
}


int[][] dp;
int[] v, w;

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}



Measured memory_bytes: 6356
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll l,r,d;
  cin>>l>>r>>d;
  cout<<r/d-(l-1)/d<<endl; 
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 3800
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    int people = 0;
    for (int i = 0; i < number; i++) {
      int first = sc.nextInt();
      int last = sc.nextInt();
      int member = last - first + 1;
      people += member;
    }
    System.out.println(people);
  }
}

Measured memory_bytes: 24548
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,m,x,y,fl=0,tu=0;
    cin>>n>>m>>x>>y;
    int a[n+2],b[m+2];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    sort(a,a+n),sort(b,b+m);
    if(b[0]>a[n-1]&&b[0]>x&&b[0]<=y)
    {
        cout<<"No War"<<nl;
    }
    else
    {
        cout<<"War"<<nl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int x,y,z;cin>>x>>y>>z;
    int ans = (x-z)/(y+z);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  
  int n,a,b, a_price;
  cin >> n >> a >> b;
  a_price = n*a;
  
  if (a_price <= b){
    cout <<  a_price << endl;
  }
  else{
    cout << b << endl;
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
using namespace std;

const long double PI = 2*acos(0);

int main(){
	ll n;cin>>n;
	ll ans = LLONG_MAX;
	ii ini = ii(1,1);
	for(ll i = 1;i*i <=n;i++){
		if(n%i == 0){
			ans = min(ans, i-1+(n/i-1));
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::cmp::max;

fn main() {
    input!{
        n: i64,
        m: i64,
    }

    let mut ans = 1;
    let mut p = 1;
    while p * p <= m {
        if m % p == 0 {
            if m / p >= n {
                ans = max(ans, p);
            }
            if p >= n {
                ans = max(ans, m / p);
            }
        }
        p += 1;
    }

    println!("{}", ans);
}


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

int main(void)
{
        int a,i,s,n;
        char b[100];

        scanf("%d%s",&a,b);

        n=strlen(b);
        s=a*(int)pow(10,n);
        for(i=0;i<n;i++)
                s+=(b[n-i-1]-'0')*pow(10,i);
        for(i=1;i<=1000;i++){
                if(i*i==s){
                        printf("Yes\n");
                        return 0;
                }
        }

        printf("No\n");
        return 0;
}


Measured memory_bytes: 2452
i=lambda:map(int,input().split());n,m=i();l=[0,1]+[0]*n;c=[0]+[1]*n
for _ in[0]*m:x,y=i();l[y]|=l[x];c[y]+=1;c[x]-=1;l[x]=c[x]and l[x]
print(sum(c[i]and l[i]for i in range(n+1)))

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

int main() {
	int n,i;
	double ans;
	cin >> n;
	vector<int> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	ans=a[0];
	for(i=1; i<n; i++){
		ans=(ans+a[i])/2.0;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 764
from subprocess import *
call(('pypy3','-c',"""
n,m = map(int,input().split())
ls = [[x for x in input() + '#'] for i in range(n)] + [['#']*(m+1)]
yokodp = [[0 for x in range(m+1)] for i in range(n+1)]
for i in range(n+1):
    yoko = 0
    for j in range(m+1):
        if ls[i][j] == '#':
            yokodp[i][j] = yoko
            yoko = 0
        else:
            yoko += 1
for i in range(n,-1,-1):
    check = 0
    for j in range(m,-1,-1):
        if yokodp[i][j] != 0:
            check = yokodp[i][j]
        if ls[i][j] == '.':
            yokodp[i][j] = check
tatedp = [[0 for x in range(m+1)] for i in range(n+1)]            
for j in range(m+1):
    tate = 0
    for i in range(n+1):
        if ls[i][j] == '#':
            tatedp[i][j] = tate
            tate = 0
        else:
            tate += 1
for j in range(m,-1,-1):
    for i in range(n,-1,-1):
        if tatedp[i][j] != 0:
            check = tatedp[i][j]
        if ls[i][j] == '.':
            tatedp[i][j] = check
ans = 0
for i in range(n):
    for j in range(m):
        if ls[i][j] == '.':
            ans = max(ans,tatedp[i][j] + yokodp[i][j] - 1)
print(ans)
"""))


Measured memory_bytes: 252148
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


int main(){
    string S;
    cin >> S;
    string T=S;
    reverse(T.begin(), T.end());
    int num=0;
    int L=S.length();
    for(int i=0;i<L;++i){
        if(S[i]!=T[i]){
            ++num;
        }
    }
    cout << num/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, P> PP;
struct edge {int to, cost;};
int a[3];
signed main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = 114514;
	do {
		ans = min(ans, abs(a[1] - a[0]) + abs(a[2] - a[1]));

	} while (next_permutation(a, a + 3));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>G[1<<17];
int c[1<<17];
int ans[1<<17];
int id;
void dfs(int u,int p)
{
	for(int v:G[u])
	{
		if(v==p)continue;
		dfs(v,u);
	}
	ans[u]=c[id++];
}
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);G[b].push_back(a);
	}
	int sum=0;
	for(int i=0;i<N;i++)
	{
		cin>>c[i];
		sum+=c[i];
	}
	sort(c,c+N);
	dfs(0,-1);
	sum-=ans[0];
	cout<<sum<<endl;
	for(int i=0;i<N;i++)cout<<ans[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 4224
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  sm=0
  add1=0
  f=1
  for i in range(n):
    sm+=l[i]
    if f==1:
      if sm<=0:
        add1+=abs(sm)+1
        sm=1
      f=-1
    else:
      if sm>=0:
        add1+=abs(sm)+1
        sm=-1
      f=1

  sm=0
  add2=0
  f=-1
  for i in range(n):
    sm+=l[i]
    if f==1:
      if sm<=0:
        add2+=abs(sm)+1
        sm=1
      f=-1
    else:
      if sm>=0:
        add2+=abs(sm)+1
        sm=-1
      f=1

  return min(add1,add2)

print(main())


Measured memory_bytes: 17264
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;

void solve()
  {
   int n;
   cin>>n;
   int cnt = n-1;
   loop(i,2,n+1)
    {
      int a = 1;
      while(a*i < n)
         {
          int c = n - a*i;
          if(c)
             cnt++;
          a++;
         }
    }
   cout<<cnt;
  } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3648
# include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main()
{
    int N;
    vec(A)
        cin >> N;
    int j = 0;

    fx(N){
        vecp(A)
            if (A.at(x) <= 0) { j++; }
    }
    ll ans = 0;
    if (j%2==0) {
        fx(N){
            ans+= abs(A.at(x));
        }
        ce(ans)
    }else {
        int mini = 1000000000;
        fx(N){
            if (mini > abs(A.at(x))){
                ans += mini;
                mini = abs(A.at(x));
            }
            else {
                ans += abs(A.at(x));
            }
        }
        ce(ans-mini-1000000000)
    }
}

Measured memory_bytes: 892
def main():
    h,w,k = map(int,input().split())
    g = []
    for _ in range(h):
        g.append(input())
    
    ans = 0
    for hb in range(0b1<<h):
        for wb in range(0b1<<w):
            temp = 0
            for i in range(h):
                for j in range(w):
                    if 0b1&hb>>i and 0b1&wb>>j:
                        if g[i][j] == "#":
                            temp+=1
            
            if temp==k:
                ans+=1
    
    print(ans)
main()

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

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

    int a = s % 100;
    int b = s / 100;

    if ((a < 13 && a!=0) && (b < 13 && b !=0)){
        cout << "AMBIGUOUS" << endl;
    }
    else if((b < 13 && b != 0)){
        cout << "MMYY"  << endl;
    }
    else  if ((a<13 && a!=0)){
        cout << "YYMM" << endl;
    }
    else { 
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  string s;
  while(cin >> s) {
      int j=0,ioi=0;
      for(int i=0; i<s.size()-2; i++) {
          if(s.substr(i,3)=="JOI") {
              j++;
          }
          else if(s.substr(i,3)=="IOI") {
              ioi++;
          }
      }
      cout << j << endl;
      cout << ioi << endl;
  }
}


Measured memory_bytes: 3132
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

int n,h[N],dp[N][2];
int rec(int i,int last){
    if(i>n) return 1e9;
    if(i==n) return abs(h[i]-(last?h[i-2]:h[i-1]));
    int &cache=dp[i][last];
    if(cache!=-1) return cache;
    return cache=abs(h[i]-(last?h[i-2]:h[i-1]))+min(rec(i+1,0),rec(i+2,1));
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n) cin>>h[i];
    memset(dp,-1,sizeof dp);
    h[0]=h[1];
    cout<<rec(1,0);
    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int noofpeople,nooffood,temp;
    cin>>noofpeople>>nooffood;
    int nofoodlike[nooffood+1]={0};
    for(int i=0;i<noofpeople;i++){
        cin>>temp;
        for(int j=0;j<temp;j++){
            int x;
            cin>>x;
            nofoodlike[x]+=1;

        }

    }
    int ans=0;
    for(int i=1;i<=nooffood;i++){
        if(nofoodlike[i]==noofpeople){
ans+=1;
}}
cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
     int r = sc.nextInt();
     int d = sc.nextInt();
     int x = sc.nextInt();
	  sc.close();
	  
	  for(int i=0; i<10; i++) {
		  x =r*x - d;
		 System.out.println(x);
	  }
	
	
	}

}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;string s;cin>>n>>s;
if(n%2==0){
for(int i=0;i<n/2;i++){
if(s.at(i)!=s.at(i+n/2)){
cout<<"No"<<endl;
return 0;
}
}
cout<<"Yes"<<endl;
return 0;
}
cout<<"No"<<endl;
}

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

int main(){
  
  double N,i,ans = 0;
  cin >> N;
  vector<double> V(N);
  for(i = 0; i < N; i++) cin >> V.at(i);
  sort(V.begin(),V.end());
  for(i = 0; i < N; i++){
    if(i == 0) ans = V.at(0);
    else{
      ans += V.at(i);
      ans /= 2;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i

h = Hash.new(0)
s = t = u = 0
M = 10 ** 9 + 7

n.times do
    a, b = gets.split.map(&:to_r)
    if a == 0 && b == 0
        s += 1
    elsif a == 0
        t += 1
    elsif b == 0
        u += 1
    else
        h[a/b] += 1
    end
end

bin = Array.new(n + 1, 1)
1.upto(n) {|i| bin[i] = bin[i-1] * 2 % M}

hh = {}
ans = (bin[t] + bin[u] - 1) % M
h.each do |k, v|
    next if hh[k] || hh[-1/k]
    hh[k] = 0
    vv = h[-1/k]
    ans = ans * (bin[v] + bin[vv] - 1) % M
end

puts (ans + s - 1) % M

Measured memory_bytes: 49568
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
string s;
int main()
{
  cin>>s;
  for(int i=0;i<s.size();i++)
    if(i%2==0)cout<<s[i];
  cout<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int N;
    cin>>N;
    vector<int> height(N, 0);
    for(int& n: height) 
        cin>>n;
    
    vector<int> dp(N, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(height[1] - height[0]);
    
    for(int i = 2; i < N; ++i ){
        int a = abs(height[i-1] - height[i]);
        int b = abs(height[i-2] - height[i]);
        dp[i] = min(dp[i-1]+a, dp[i-2]+b);
    }

    cout<<dp[N-1]<<endl;
}

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

int n;
ll res = (ll)1e16;
int arr[200010];

ll f(ll a){
	int i;
	ll nres = 0ll;
	for(i = 0; i < n; i++) nres += abs(arr[i] - a - i); return nres;
}
int main(){
	int i;
	ll l, r, m1, m2;
	ll nres1, nres2;
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &arr[i]);
	l = -(ll)2e9; r = (ll)2e9;
	while(l <= r){
		m1 = (2*l + r) / 3; m2 = (l + 2*r) / 3;
		nres1 = f(m1); nres2 = f(m2);
		res = min(res, min(nres1, nres2));
		if(nres1 < nres2) r = m2 - 1;
		else l = m1 + 1;
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 1024
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second


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

  int k;
	cin >> k;
  int count = 0;
  FOR(i, 1, k){
    FOR(j, 1, k){
      int g;
      g = gcd(i, j);
      FOR(l, 1, k){
        count += gcd(l, g);
      }
    }
  }
	cout << count << "\n";
}


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

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], A[i] -= i;
    sort(A.begin(), A.end());
    long long mid = A[N/2];
    long long res = 0;
    for (int i = 0; i < N; ++i) res += abs(A[i] - mid);
    cout << res << endl;
}


Measured memory_bytes: 1792
open System

[<EntryPoint>]
let main argv =
    let a = stdin.ReadLine().ToCharArray()
    let b k = Char.IsUpper(k)
    let acase k = 
        match k with
        | true -> printfn "A"
        | false -> printfn "a"
        | _ -> printfn "non char"

    a.[0] |> b |> acase
    
    0 


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int M, N;
int W[200100], T[200100];
int C[20], B[20];
int dp[1<<15];

inline int sumW(int i, int j){
    return W[i] - W[j + 1];
}

inline int sumT(int i, int j){
    return T[i] - T[j + 1];
}

template <class Pred>
int lb(int l, int r, Pred p){
    while(r - l > 1){
        int m = (l + r) / 2;
        if(p(m)){
            l = m;
        }else{
            r = m;
        }
    }
    return l;
}

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

    std::cin >> M >> N;

    for(int i=0;i<M;++i){
        std::cin >> W[i] >> T[i];
    }

    for(int i=M-2;i>=0;--i){
        W[i] += W[i + 1];
        T[i] += T[i + 1];
    }

    for(int i=0;i<N;++i){
        std::cin >> C[i] >> B[i];
    }

    for(int i=0;i<(1<<N);++i){
        for(int j=0;j<N;++j){
            if(i >> j & 1){
                continue;
            }

            int k = dp[i], l = lb(k, M + 1, [&](int l){return C[j] >= sumW(k, l - 1) && B[j] >= sumT(k, l - 1);});

            dp[i | (1 << j)] = std::max(dp[i | (1 << j)], l);
        }
    }

    int mx = dp[(1<<N)-1];
    std::cout << mx << std::endl;
}



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

typedef long long ll;

int n;
ll a[100000] = {};

ll solve(bool judge){
    ll sum = 0, score = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(judge){
            if(sum <= 0){
                score += 1-sum;
                sum = 1;
            }
        }else{
            if(sum >= 0){
                score += sum+1;
                sum = -1;
            }
        }
        judge = !judge;
    }
    return score;
}

int main(){
    cin >> n;

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

    ll first = solve(true);
    ll second = solve(false);

    cout << min(first, second) << endl;

    return 0;
}

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

int main() {
  string c;
  cin >> c;
  
  if(c=="a"||c=="e"||c=="i"||c=="o"||c=="u"){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,string> P;

int main(){
    int n, m;
    cin >> n >> m;
    int a = 0;
    int c = 0;
    map<int,vector<string>> mp;
    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        mp[p].push_back(s);
    }
    for(auto m:mp){
        int cc = 0;
        bool chk = false;
        for(auto mm:m.second){
            if(mm == "WA" && !chk)++cc;
            else if(mm == "AC" && !chk){
                ++a;
                chk = true;
            }
            else continue;
        }
        if(chk)c+= cc;
    }
    cout << a << " " << c << endl;
}

Measured memory_bytes: 15872
#include <stdio.h>

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

    int surplus = 0;
    int ans = 1;
    while(1){
        if (ans > k) { puts("-1"); return 0; }
        surplus = ((surplus * 10) + 7) % k;
        if (!surplus) break;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 1732
#include <iostream>


using namespace std;

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

    if(R >= 2800){
        cout << "AGC" << endl;
    }else if(R >= 1200){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[10000];
  vector<long long> v;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n;i++)
    for(int j=0;j<=3&&j<n;j++){
      if(i==j)continue;
      long long s=a[i];
      for(int k=0;k<=(int)log10(a[j]);k++)s*=10;
      v.push_back(s+a[j]);
    }
  sort(v.begin(),v.end());
  cout<<v[2]<<endl;
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

int n;
int a[MX1];

void solve(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(int i=1;i<=n+1;i++){
		sum+=abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;i++){
		int req=sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]);
		cout<<req<<"\n";
	}
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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


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

    int *H;
    H = (int*)malloc(N * sizeof(int));

    int i;
    double min = 10000.0;
    int bestI = -1;
    double t;
    for(i=0; i<N; i++) {
        scanf("%d", &H[i]);
        t = (double)T - (double)H[i] * 0.006;
        if(fabs((double)A - t) < min) {
            min = fabs((double)A - t);
            bestI = i + 1; 
        }
    }

    printf("%d\n", bestI);

    free(H);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int ball_cnt[200001];
int A[200001];
int main()
{
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    ball_cnt[i] = 0;
  }

  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    ball_cnt[A[i]]++;
  }

  long long sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += (long long)(ball_cnt[i]) * (ball_cnt[i]-1) / 2;
  }
  
  for (int i = 1; i <= N; i++) {
    int num = A[i];
    long long ans = sum;
    ans -= (ball_cnt[num]) * (ball_cnt[num]-1) / 2;
    ans += (ball_cnt[num]-1) * (ball_cnt[num]-2) / 2;

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


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            if(i % 2 == 0){
                if(s.charAt(i) == '0'){
                    count++;
                }
            }else{
                if(s.charAt(i) == '1'){
                    count++;
                }
            }
        }
        
        if(count > (s.length() / 2)){
            count = s.length() - count;
        }
        
        System.out.println(count);
    }
}

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

const int MaxN = 710;

int n, m, cnt, ans = 0x3f3f3f3f, col[MaxN], num[3];
bool f[MaxN][MaxN], g[MaxN][MaxN];

bool dfs(int u, int c) {
	col[u] = c; num[c]++;
	for (int i = 1; i <= n; i++) {
		if (!g[u][i]) {
			if (!col[i]) {
				if (!dfs(i, 3 - c)) 
					return 0;
			}
			else if (col[i] == c) return 0; 
		}
	}
	return 1;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u][v] = g[v][u] = 1;
	}
	for (int i = 1; i <= n; i++) g[i][i] = 1;
	f[0][0] = 1;
 	for (int i = 1; i <= n; i++) {
		if (!col[i]) {
			num[1] = num[2] = 0;
			if (!dfs(i, 1)) {
				puts("-1");
				return 0;
			}
			cnt++;
			for (int j = 0; j <= n; j++)
				if (f[cnt - 1][j])
				f[cnt][j + num[1]] = f[cnt][j + num[2]] = 1;
		}
	}
	
	for (int i = 0; i <= n; i++)
		if (f[cnt][i]) ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4632
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
  auto X=readln.chomp.to!int;
  auto A=readln.chomp.to!int;
  auto B=readln.chomp.to!int;
  writeln((X-A)%B);
}  

Measured memory_bytes: 256
A=[chr(i) for i in range(65, 65+26)]
N=int(input())
S=str(input())
T=[]
U=str()

for i in range(len(S)):
  k=(A.index(S[i])+N)%26
  T.append(A[k])
  U=U+str(T[i])
  
print(U)

Measured memory_bytes: 3188
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let a = read::<u32>();
    let b = read::<u32>();
    let c = read::<u32>();
    let d = read::<u32>();
    let e = read::<u32>();

    let v = vec![a, b, c, d, e];
    let mut min = 10;
    for i in &v {
        let i10 = i % 10;
        if i10 > 0 && i10 < min {
            min = i10;
        }
    }
    let time_min = v.iter().map(|&i| {
        if i % 10 == 0 {
            i
        } else {
            (i / 10 + 1) * 10
        }
    }).fold(0, |sum, x| sum + x) - (10 - min);

    println!("{}", time_min);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

/*
int main(){
  int n;cin>>n;
  string s;cin>>s;
  unordered_map<string, int> mp ;
  for (int i = 0; i < n; i++) {
  for (int j = i+1; j < n; j++) {
  for (int k = j+1; k < n; k++) {
    string tmp;
    tmp += s.at(i);
    tmp += s.at(j);
    tmp += s.at(k);
    //cout << tmp << endl;
    mp[tmp]++;
  }}}
  cout << mp.size() << endl;
}

*/

int main()
{
  ll ans = 0;
  int n;cin >> n;
  string s;cin >>s;

  for (int i = 0; i < 1000; i++) {
    int tmp = i;
    char t[3];
    t[0] = char('0' + (tmp / 100));
    tmp %= 100;
    t[1] = char('0' + (tmp / 10 ));
    tmp %= 10;
    t[2] = char('0' + (tmp));

    //cout << t[0] << t[1] << t[2] << endl;
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (t[cnt] == s[j])cnt++;
      if (cnt == 3)break;
    }
    if(cnt >= 3)ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll X,Y;

void run() {
	scanf("%lld%lld",&X,&Y);
	printf("%s\n",abs(X-Y)<=1?"Brown":"Alice");
}

int main() {
	run();
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int r,D,x2000;
    cin >> r >> D >> x2000;

    for(int i=0;i<10;i++){
        x2000 = x2000*r-D;
        cout << x2000 << endl;
    }

}



Measured memory_bytes: 256
input()
n=list(map(int,input().split()))
a = False
for i in n:
    if i%2 == 0 :
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            a = True
            break

if a:
    print('DENIED')
else:
    print('APPROVED')


Measured memory_bytes: 2940
#include <stdio.h>

int main() {
    int i;
    int A[5];
    int k;
    int count=0;
    for(i=0;i<5;++i){
        scanf("%d", &A[i]);
    }
    scanf("%d", &k);

    for(i=4;i>=0;--i){
        for(int j=0;j<5;++j){
            if(A[i]-A[j] <= k){continue;}else{printf(":(");return 0;}
        }

    }
    printf("Yay!");

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();
		int ans = Math.max(num3 -num1 + num2, 0);
		System.out.println(ans);
	}
}




Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint n;
    cin >> n;
    
    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    vector<lint> b(n), c(n);
    map<lint, lint> bm, cm;
    for(int i=0; i<n; i++) {
        b[i] = a[i] + i;
        bm[b[i]]++;
        c[i] = i - a[i];
        cm[c[i]]++;
    }

    lint ans = 0;
    for(auto [key, value] : bm) {
        ans += value * cm[key];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 42256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    if (a > 9 || b > 9) {
        cout << -1 << "\n";
        return 0;
    } else {
        cout << a * b << "\n";
    }
}

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

int dp[100010], n, h[100010];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	dp[1] = 0, dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++)
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n,r;
	cin >> n >> r;
	if(n >= 10)
		cout << r;
	else cout << r + 100 * (10 - n);
}


Measured memory_bytes: 256
// F.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,v) for (auto it=v.begin(); it!=v.end(); ++it)
#define FORANGE(it, v) for (auto it : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()


template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}

int main()
{
	lolo N;
	cin >> N;
	vec S(N);
	FOR(i, N) cin >> S[i];
	// N-1の約数の個数?

	lolo ans = 0;

	FORN(C,1, N) {
		set<lolo> usedIndexSet;
		lolo nowScore = 0;
		lolo score = 0;
		lolo nowA = N - 1;
		const auto k_MAX = N ;
		FORN(k, 1, k_MAX+1) { 
			auto A2 = nowA - C;
			auto B = A2 - C;
			
			if (B > 0); else break;
			if (A2 != k * C); else continue;			

			if (!((usedIndexSet.count(k * C) == 0) and (usedIndexSet.count(A2 ) == 0))) {
				break;
			}

			usedIndexSet.insert(k * C);//kCとA2が追加される。
			usedIndexSet.insert(A2);
			score += S[k * C];
			score += S[A2];
			chmax(ans, score);

			nowA =A2;

		}
	}
	cout << ans << endl;
	
}

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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf  1e18
#define mk(arr,n,type) type *arr=new type[n];
#define ti(arr,n) for(ll i=0;i<n;++i)cin>>a[i];
#define ot(arr,n) for(ll i=0;i<n;++i)cout<<a[i]<<" ";
#define str(a) string a;cin>>a;
#define w(x) int x;cin>>x;while(x--)
int main()
{
	string a;
	cin >> a;
	int l = a.length();
	if (a[l - 1] == 's')
	{
		cout << a << "es";
	}
	else
		cout << a << "s";
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int N;
    long T;
    cin >> N >> T;
    long t[N];
    int tmp = 0;
    int total = 0;
    REP(i, N) cin >> t[i];
    FOR(i, 1, N){
        tmp = t[i] - t[i - 1];
        if(tmp <= T)
            total += tmp;
        else
            total += T;
    }
    total += T;
    cout << total << endl;
    return 0;
}

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

using namespace std;
typedef vector<int> vi;
#define REP(i, n) for (int i = 0; i < n; ++i)

const int MAX = 111;
int N;
int cnt[MAX];

int main() {
    cin >> N;
    int mx = 0, mn = MAX;
    REP (i, N) {
        int a;
        cin >> a;
        cnt[a]++;
        mx = max(mx, a);
        mn = min(mn, a);
    }

    bool ans = true;
    if (mx%2) { // 最大が奇数なら、最小はmx/2+1で2つだけある
        ans = (mn == mx/2+1 && cnt[mn] == 2);
    } else { // 偶数なら、最小はmx/2で1つだけ
        ans = (mn == mx/2 && cnt[mn] == 1);
    }
    for (int x = mn+1; x <= mx; x++) {
        ans &= (cnt[x] >= 2);
    }
    cout << ((ans)?"Possible":"Impossible") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll A, B, C, X, Y;;
    cin >> A >> B >> C >> X >> Y;
    if(X > Y){
        swap(X, Y);
        swap(A, B);
    }
    //X <= Y
    ll ans = (Y - X) * B + min(A + B, 2 * C) * X;
    ll ans2 = Y*2*C;
    cout << min(ans, ans2) << endl;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    long long arr[n+1][3];
    for(int i=1;i<=n;i++)
        {
        for (int j=0;j<3;j++)
            cin>>arr[i][j];
        }
    long long maxi=  -(1LL << 60);
    for(int k=0;k<8;k++)
        {
         vector<long long>v;
    for(int i=1;i<=n;i++)
        {
          long long cnt=0;
        for(int j=0;j<3;j++)
            {
                if((k/(1<<j))%2==0)
                {
                    cnt+=arr[i][j];
                }
                else cnt-=arr[i][j];

            }
        v.push_back(cnt);
        }
        sort(v.begin(),v.end());
        reverse(v.begin(), v.end());
        long long ans=0;
        for(int i=0;i<m;i++)ans+=v[i];
        maxi=max(maxi,ans);
    }
    cout<<maxi;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List
import Data.Char

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine :: IO [Int]
    ss <- getLine
    let c1 = take a ss
    let c2 = head $ drop a ss
    let c3 = take b $ drop (a + 1) ss
    if and [ all isAlphaNum c1
           , c2 == '-'
           , all isAlphaNum c3
           ]
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
	string s,s1="CODEFESTIVAL2016";
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 16; i++) {
		if (s[i] != s1[i])ans++;
	}
	cout << ans << endl;
}

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

ll solve() {
    ll N, D;
    cin >> N >> D;
    return (N + ( 2 * D )) / ( 2 * D + 1);    
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384