akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  map<ll, ll> m;
  rep(i, n) {
    ll a; cin >> a;
    if (m.find(a) == m.end()) m.insert(make_pair(a, 1));
    else m[a]++;
  }
  int ans = 0;
  for (auto it = m.begin(); it != m.end(); it++)
    if (it->second % 2 == 1) ans++;
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 6528
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int dp[N];
ll add(ll a,ll b){
  return ((a%M)+(b%M))%M;
}
ll sub(ll a,ll b){
  return ((a%M)-(b%M)+M)%M;
}
void solve(){
  int n,k;cin>>n>>k;
  vi a(n);
  rep(i,0,n-1)cin>>a[i];
  //dp[i][j] is the ans for i children considered and j candies distributed
  // (i>=x)dp[i][j]=x+dp[i-x][j-1];
  dp[0]=1;
  vi p(k+1,0);
  rep(i,0,n-1){
    p=vi(k+1,0);
    per(j,k,0){
      int l=j+1;
      int r=min(j+a[i],k);
      if(l<=r){
        p[l]=add(p[l],dp[j]);
        if(r<k)p[r+1]=sub(p[r+1],dp[j]);
      }
    }
    int pref=0;
    rep(j,0,k){
      pref=add(pref,p[j]);
      dp[j]=add(dp[j],pref);
    }
  }
  cout<<dp[k];
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 2656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 200009	//VS内でoverflowさせない

int main() {
	int n, i, count[N], max = 0;
	char s[N][11];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}
	qsort(s, n, 11, strcmp);	//strcmpでabc～

	count[0] = 1;
	for (i = 1; i < n; i++) {
		if (strcmp(s[i - 1], s[i]) == 0) {
			count[i] = count[i - 1] + 1;
		}
		else {
			count[i] = 1;
			if (max < count[i - 1]) {
				max = count[i - 1];
			}
		}
	}
	
	if (max < count[n - 1])max = count[n - 1];
	for (i = 0; i < n; i++) {
		if (max == count[i])printf("%s\n", s[i]);
	}
	return 0;
}

Measured memory_bytes: 5244
#include <cstdio>
#include <algorithm>
#include <functional>
#include <set>
using namespace std;

using i32 = int;
using i64 = long long;

#define REP(i, stop) for (register int i = 0; i < stop; ++i)

template<typename T>
T read() {
  T a = 0;
  register int c;
  for(;;) {
    c = getchar_unlocked();
    if (c & 16) {
      a = a * 10 + c - 48;
    } else {
      return a;
    }
  }
}

void writeln(i64 a) {
  char buf[20];
  register int i = 0;
  // if (a <= 0)
  while (a > 0) {
    buf[i++] = a % 10;
    a = a / 10;
  }
  while (i > 0) {
    putchar_unlocked(buf[--i] + 48);
  }
  putchar_unlocked('\n');
}

i64 A[1000], B[1000], C[1000];
i64 ABC[3000];
signed main() {
  i32 X = read<i32>(),
      Y = read<i32>(),
      Z = read<i32>(),
      K = read<i32>();
  REP(i, X) A[i] = read<i64>();
  REP(i, Y) B[i] = read<i64>();
  REP(i, Z) C[i] = read<i64>();
  sort(A, A + X, greater<i64>());
  sort(B, B + Y, greater<i64>());
  sort(C, C + Z, greater<i64>());
  i64 A0 = A[0],
      B0 = B[0],
      C0 = C[0];
  REP(i, X) A[i] = A0 - A[i];
  REP(i, Y) B[i] = B0 - B[i];
  REP(i, Z) C[i] = C0 - C[i];
  i64 l = 0,
      r = A0 + B0 + C0,
      m;
  while (l < r) {
    m = (l + r) / 2;
    i32 cnt = 0;
    REP(i, X) {
      if (A[i] > m) break;
      REP(j, Y) {
        if (A[i] + B[j] > m) break;
        REP(k, Z) {
          if (A[i] + B[j] + C[k] > m) break;
          ++cnt;
          if (cnt >= K) {
            r = m;
            goto NEXT;
          }
        }
      }
    }
    l = m + 1;
    NEXT:;
  }
  i32 c = 0;
  REP(i, X) {
    if (A[i] >= l) break;
    REP(j, Y) {
      if (A[i] + B[j] >= l) break;
      REP(k, Z) {
        if (A[i] + B[j] + C[k] >= l) break;
        ABC[c++] = A[i] + B[j] + C[k];
      }
    }
  }
  sort(ABC, ABC + c);
  REP(i, c) {
    writeln(A0 + B0 + C0 - ABC[i]);
  }
  REP(_, K - c) {
    writeln(A0 + B0 + C0 - l);
  }
}

Measured memory_bytes: 256
/* ex 7_1
   アカウント名 */

#include <stdio.h>


typedef struct point{
    int x_elem;
    int y_elem;
}point;

point shift_point(point base, int x_diff, int y_diff){
    point new_point;
    new_point.x_elem = base.x_elem + x_diff;
    new_point.y_elem = base.y_elem + y_diff;
    return new_point;
}

int main(void){
    int x_elem1, x_elem2, y_elem1, y_elem2;
    int x_diff, y_diff;
    point vec1, vec2, vec3, vec4;
    scanf("%d %d %d %d", &x_elem1, &y_elem1, &x_elem2, &y_elem2);
    vec1.x_elem = x_elem1;
    vec1.y_elem = y_elem1;
    vec2.x_elem = x_elem2;
    vec2.y_elem = y_elem2;
    x_diff = vec2.x_elem - vec1.x_elem;
    y_diff = vec2.y_elem - vec1.y_elem;
    vec3 = shift_point(vec2, -y_diff, x_diff);
    vec4 = shift_point(vec1, -y_diff, x_diff);
    printf("%d %d %d %d\n", vec3.x_elem, vec3.y_elem, vec4.x_elem, vec4.y_elem);
    return 0;
}

Measured memory_bytes: 1736
import java.util.*;
public class Main
{public static void main(String[] args) {
		Scanner input=new Scanner (System.in);
		long a=input.nextLong();
		long b=a;
		int count=0;
		long sum1=0;
		long sum=0;
		long sum2=0;
		long sum3=0;
	if(a<10){
	sum3=a;
	}else{
		while(a>0) {
			if(a<10) {
				sum1= a;
			}
			sum2+=a%10;
			a/=10;
			count++;
		}
		sum=(count-1)*9+sum1-1;
		sum3=Math.max(sum2, sum);
		}
		System.out.println(sum3);
	}
	
}

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

using namespace std;

const int SIZE_LIMIT = 2e5+5;
char arr[SIZE_LIMIT];

int main() {
  memset(arr, 0, sizeof(arr));

  scanf("%s", arr);
  int sum = 0;
  for (int i = 0; i < strlen(arr); ++i) {
    sum += arr[i] - '0';
  }
  const char* ans[2] = {"No", "Yes"};
  printf("%s\n", ans[sum%9==0]);
  return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


const int dm = 1 << 21;
char dn[dm], *di = dn, dt;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = ' ';
		return;
	}
	int keta = 0;
	char C[7];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = ' ';
}

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


	int M, K;
	cin >> M >> K;

	if (M == 0) {
		if (K == 0) cout << "0 0" << endl;
		else co(-1);
	}
	else if (M == 1) {
		if (K == 0) cout << "0 0 1 1" << endl;
		else co(-1);
	}
	else {
		if ((1 << M) <= K) {
			co(-1);
		}
		else {
			putint(K);
			rep(i, 1 << M) {
				if (i != K) putint(i);
			}
			putint(K);
			rep(i, 1 << M) {
				if ((1 << M) - 1 - i != K) putint((1 << M) - 1 - i);
			}
			fwrite_unlocked(dn, di - dn, 1, stdout);
		}
	}
	Would you please return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= n; i++) {
                String[] st = br.readLine().split(" ");
                String e = st[0];
                Long p = Long.parseLong(st[1]);
                Long q = Long.parseLong(st[2]);
                data.merge(e, p * q, Long::sum);
            }
            
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000L)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0L) { System.out.println("NA"); }
        }
    }
}

Measured memory_bytes: 32024
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    int p[a],q[b],r[c];
    for(int i=0;i<a;i++)
        cin >> p[i];
    for(int i=0;i<b;i++)
        cin >> q[i];
    for(int i=0;i<c;i++)
        cin >> r[i];
    sort(p,p+a),sort(q,q+b),sort(r,r+c);
    int s[x],t[y];
    for(int i=0;i<x;i++)
        s[i]=p[a-1-i];
    for(int i=0;i<y;i++)
        t[i]=q[b-1-i];
    int i=x-1,j=y-1,k=c-1;
    int T=1000000;
    while(i>=0 or j>=0){
        T--;
        if(!T)break;
        if(i<0){
            if(t[j]<r[k])
                t[j]=r[k],k--,j--;
            else break;
        }
        else if(j<0){
            if(s[i]<r[k])
                s[i]=r[k],i--,k--;
            else break;
        }
        else{
            if(r[k]<=min(s[i],t[j]))break;
            if(s[i]<t[j]){
                if(s[i]<r[k])
                    s[i]=r[k],i--,k--;
            }
            else{
                if(t[j]<r[k])
                    t[j]=r[k],k--,j--;
            }
        }
        if(k<0)break;
    }
    int ans=0;
    for(int i=0;i<x;i++)ans+=s[i];
    for(int j=0;j<y;j++)ans+=t[j];
    cout << ans;
}


Measured memory_bytes: 3968
_ = int(input())

num_list = list(map(int, input().split()))

count = 0
is_all_even = None 
while True:
    for num in num_list:
        if num % 2 != 0:
            is_all_even = False
            break
    if is_all_even is not None:
        break
    count += 1
    num_list = list(map(lambda x: x / 2, num_list))
print(count)







Measured memory_bytes: 3316
object Main extends App {
  val Array(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = {
    val min = List(h, w).min
    val max = List(h, w).max
    if (min == 1) {
      1
    } else {
      // 偶数, 偶数
      if (min % 2 == 0 && max % 2 == 0) {
        (BigInt(h) * w) / 2
      } else if (min % 2 != 0 && max % 2 != 0) {
        // 奇数, 奇数
        ((BigInt(h) * (w - 1)) / 2) + (BigInt(h) / 2) + 1
      } else {
        // 奇数, 偶数
        (BigInt(h) * w) / 2
      }
    }
  }


  println(ans)
}


Measured memory_bytes: 54908
#include <stdio.h>
#include <stdlib.h>

int n;

void maxHeapify(long* array, int i) {
	int l, r, largest;
	long work;
	
	l = i * 2;
	r = i * 2 + 1;
	
	if (l <= n && array[l] > array[i]) {
		largest = l;
	} else {
		largest = i;
	}
	
	if (r <= n && array[r] > array[largest]) {
		largest = r;
	}
	
	if (largest != i) {
		work = array[i];
		array[i] = array[largest];
		array[largest] = work;
		maxHeapify(array, largest);
	}
}

void buildMaxHeap(long* array) {
	int i;
	for (i = n / 2; i >= 1; i--) {
		maxHeapify(array, i);
	}
}

int main(void) {
	int i;
	long *heap = NULL;
	scanf("%d", &n);
	
	heap = (long*)malloc(sizeof(long) * (n + 1));
	
	for (i = 1; i <= n; i++) {
		scanf("%ld", &heap[i]);
	}
	
	buildMaxHeap(heap);

	for (i = 1; i <= n; i++) {
		printf(" %ld", heap[i]);
	}
	printf("\n");

	return 0;
}



/*
1
23
4567
89101112
*/

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

int main() {
	int k,a,b;
	cin>>k>>a>>b;
	int d=b/k;
	if((a<=k*d)&&(k*d<=b))cout <<"OK"<<endl;
	else cout<<"NG"<<endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 100005;
//////////////////////////////

string L;
int n;
Int dp[N][2];

void solve()
{
	cin >> L;
	n = L.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		//equal
		if (L[i] == '0') dp[i + 1][0] += dp[i][0];
		else dp[i + 1][0] += (2 * dp[i][0]);
		dp[i + 1][0] %= MOD;

		//less
		dp[i + 1][1] += (3 * dp[i][1]);
		if (L[i] == '1') dp[i + 1][1] += dp[i][0];
		dp[i + 1][1] %= MOD;
	}

	cout << (dp[n][0] + dp[n][1]) % MOD << endl;

}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}


Measured memory_bytes: 5312
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000001LL //2e18
#define SIZE 100010


int main(){
  int n;
  ll a,b,s[SIZE];
  int sum[SIZE] = {};

  scanf("%d%lld%lld",&n,&a,&b);

  if(a > b) swap(a,b);

  s[0] = -LLINF;
  s[n+1] = LLINF;
  for(int i=1;i<=n;i++){
    scanf("%lld",s+i);

    if(s[i] >= s[i-1]+a) sum[i] = 1;
  }
  sum[n+1] = 1;

  for(int i=0;i<=n;i++){
    sum[i+1] += sum[i];
  }
  
  ll dp[SIZE][3] = {};

  dp[1][0] = 1;
  dp[1][1] = 1;
  int r = 0;
  
  for(int i=1;i<=n;i++){
    while(s[r]-s[i] < b) r++;
    
    //0 -> y
    dp[i+1][2] = (dp[i+1][2] + dp[i][0])%mod;
    //0 -> x
    if(s[i+1] - s[i] >= a)
      dp[i+1][0] = (dp[i+1][0] + dp[i][0])%mod;
    
    if(r <= n+1){
      if(i+1 == r){
        dp[r][1] = (dp[r][1] + dp[i][1] + dp[i][2])%mod; //yyy
        
        dp[r][0] = (dp[r][0] + dp[i][1])%mod; //yyx
        
        if(s[i+1]-s[i-1] >= a)
          dp[r][0] = (dp[r][0] + dp[i][2])%mod; //xyx

      }else if(r >= i+2){
        if(sum[r]-sum[i+1] == (r-i)-1){
          dp[r][0] = (dp[r][0] + dp[i][1])%mod; //yy[x..x]x
          if(s[i+1]-s[i-1] >= a){
            dp[r][0] = (dp[r][0] + dp[i][2])%mod; //xy[x..x]x
          }
        }
        
        if(sum[r-1]-sum[i+1] == (r-i)-2){
          dp[r][2] = (dp[r][2] + dp[i][1])%mod; //yy[x..x]y
          
          if(s[i+1]-s[i-1] >= a){
            dp[r][2] = (dp[r][2] + dp[i][2])%mod; //xy[x..x]y
          }
        }
      }
    }
    //cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
  }
  
  cout << (dp[n+1][1] + dp[n+1][2])%mod << endl;
  
  return 0;
}


Measured memory_bytes: 3840
class Node:
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right


n = int(input())
binary_tree = [Node() for i in range(n)]
h, d = [0 for j in range(n)], [0 for k in range(n)]


def set_height(u):
    h1 = h2 = 0
    if binary_tree[u].right != -1:
        h1 = set_height(binary_tree[u].right) + 1
    if binary_tree[u].left != -1:
        h2 = set_height(binary_tree[u].left) + 1

    h[u] = max(h1, h2)
    return h[u]


def set_depth(u, dep):
    d[u] = dep
    if binary_tree[u].right != -1:
        set_depth(binary_tree[u].right, dep+1)
    if binary_tree[u].left != -1:
        set_depth(binary_tree[u].left, dep+1)

    return d[u]


def set_sibling(u):
    if binary_tree[binary_tree[u].parent].left != u:
        return binary_tree[binary_tree[u].parent].left
    else:
        return binary_tree[binary_tree[u].parent].right


def set_degree(u):
    cnt = 0
    if binary_tree[u].left != -1:
        cnt += 1
    if binary_tree[u].right != -1:
        cnt += 1
    return cnt


def set_type(u):
    if binary_tree[u].parent == -1:
        return "root"
    elif binary_tree[u].left == -1 and binary_tree[u].right == -1:
        return "leaf"
    else:
        return "internal node"


def main():
    for i in range(n):
        idx, left, right = map(int, input().split())
        binary_tree[idx].left = left
        binary_tree[idx].right = right
        if left != -1:
            binary_tree[left].parent = idx
        if right != -1:
            binary_tree[right].parent = idx

    # 根の探索
    root_idx = 0
    for i in range(n):
        if binary_tree[i].parent == -1:
            root_idx = i
            break

    # 各ノードの高さを求める
    set_height(root_idx)

    # 各ノードの深さを求める
    set_depth(root_idx, 0)

    for i in range(n):
        print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, "
              "height = {}, {}".format(i, binary_tree[i].parent,
                set_sibling(i), set_degree(i), d[i], h[i], set_type(i)))


if __name__ == '__main__':
    main()



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

int main() {
    int n, a, b;
    scanf ("%d %d %d", &n, &a, &b);
    
    int ans = 0, t;
    for (int i=0; i<n; i++) {
        scanf ("%d", &t);
        ans += (t < a || t >= b);
    }
    printf ("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
program abc166e
  use iso_fortran_env
  implicit none
  integer(int64) :: n, i, t
  integer(int64),allocatable :: a(:), x(:), y(:)
  read *, n
  allocate(a(n),x(n),y(n))
  read *, a
  x = 0
  y = 0
  do i = 1,n
     t = i + a(i)
     if (t < n) x(t) = x(t) + 1
     t = i - a(i)
     if (t > 1) y(t) = y(t) + 1
  end do
  print *, sum(x*y)
end program abc166e


Measured memory_bytes: 7732
// inputに入力データ全体が入る
function Main(str) {
  const nums = str.split('\n')[1].split(' ');

  const numsCast = nums.map(num => +num);

  const max = +Math.max(...numsCast);
  const min = +Math.min(...numsCast);

  console.log(max - min);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
import Data.List

main = interact $ unlines . map (show . surface_area_of_QP) . init . groupAt 2 . map read . lines

surface_area_of_QP [x,h] = x^2 + 4 * (x/2) * sqrt ((x/2)^2 + h^2)

groupAt n [] = []
groupAt n xs = take n xs : groupAt n (drop n xs)

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

int main(){
  int N;
  cin>>N;
  int ans=2147483647;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    ans = min(ans, a+b);
  }
  
  cout << ans << endl;
}




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

int main()
{
  int n,f=0,i;
  
  scanf("%d\n",&n);
  
  char str[n];
  scanf("%s",str);
  
  if(n%2!=0)
    f=1;
  else{
         for(i=0;i<n/2;i++)
         {
           if(str[i]!=str[i+n/2])
             f=1;
         }
  }
  if(f==0)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}
           

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

int main() {

	int mountain[10];
	for (int i = 0; i < 10; i++)
		cin >> mountain[i];
	sort(mountain,mountain+10);
	for(int i=9;i>=7;i--)
	cout << mountain[i] << endl;

	return 0;

}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<iomanip>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    cout<<setprecision(15);
    int n;
    cin>>n;
    double x[n],y[n];//座標
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    double sum=0;//距離の合計
    for (int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            sum=sum+sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout<<sum*2/n<<endl;
    return 0;
}

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

using namespace std;

bool solve(const string& s){
  if(s.size() < 6) return false;
  bool is1=false, is2=false, is3=false;
  for(int i=0; i<s.size(); ++i){
    if(isdigit(s[i])) is1=true;
    if(islower(s[i])) is2=true;
    if(isupper(s[i])) is3=true;
  }
  return is1 && is2 && is3;
}

int main(){
  string s;
  cin >> s;
  if(solve(s)) cout << "VALID" << endl;
  else cout << "INVALID" << endl;
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
   
typedef long long int64;
const int INF = 1 << 30;
   
vector< int > edge[13];
  
bool back(string str, int cnt){ //枝刈り大事だな
  int X[]={ 2, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 2};
  int Y[]={ 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4};
 
  int diff = 0;
  for(int i = 0; i < 13; i++){
    if(str[i] != '0'){
      int pos = (str[i] >= 'A' ? str[i] - 'A' + 10 : str[i] - '0');
      diff += abs( X[pos] - X[i]) + abs( Y[pos] - Y[i]);
    }
  }
  return diff + cnt > 20;
}
  
  
int bfs(string mas){
  
  queue< string > que;
  map< string , int > memo;
  que.push( mas );
  memo[mas] = 0;
  while(!que.empty()){
  
    string p = que.front(); que.pop();
    if(back( p, memo[p])) continue;
    if(p == "0123456789AB0") return memo[p];
  
    for(int i = 0; i < 13; i++){
      if(p[i] == '0') {
        for(int j = 0; j < edge[i].size(); j++){
          string next = p;
          swap( next[i], next[edge[i][j]]);
          if(memo.find(next) != memo.end()) continue;
          que.push( next );
          memo[next] = memo[p] + 1;
        }
      }
    }
  }
  return -1;
}
  
int main(){
  vector< int > mas(13);
  
  edge[0].push_back(2);
  edge[1].push_back(2); edge[1].push_back(5);
  edge[2].push_back(0); edge[2].push_back(1); edge[2].push_back(3); edge[2].push_back(6);
  edge[3].push_back(2); edge[3].push_back(7);
  edge[4].push_back(5);
  edge[5].push_back(1); edge[5].push_back(4); edge[5].push_back(6); edge[5].push_back(9);
  edge[6].push_back(2); edge[6].push_back(5); edge[6].push_back(7); edge[6].push_back(10);
  edge[7].push_back(3); edge[7].push_back(6); edge[7].push_back(8); edge[7].push_back(11);
  edge[8].push_back(7);
  edge[9].push_back(5); edge[9].push_back(10);
  edge[10].push_back(6); edge[10].push_back(9); edge[10].push_back(11); edge[10].push_back(12);
  edge[11].push_back(7); edge[11].push_back(10);
  edge[12].push_back(10);
  
  while(cin >> mas[0], mas[0] != -1){
    for(int i = 1; i < 13; i++){
      cin >> mas[i];
    }
  
    string start = "";
    for(int i = 0; i < 13; i++){
      if(mas[i] >= 10) start += (char)(mas[i] - 10 + 'A');
      else start += mas[i] + '0';
    }
    int ret = bfs(start);
    if(~ret) cout << ret << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 2544
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int i, ans;

    for (i = 1; i <= b;i++){
        ans = a * i % b;
        if(ans ==c){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll h ,w;
ll d[10][10];
ll flag;

void f(ll dd[16]){
	ll d1[10][10];
	clr(d1,0);
	ll x = 0;
	ll y = 0;
	rep(i,0,16){
		d1[y][x] = 1;
		if(x==w-1&&y==h-1)break;
		if(dd[i]==1){
			x++;
		}
		else{
			y++;
		}
		if(x>=w)return;
		if(y>=h)return;
	}
	ll flag1 = 1;
	rep(y,0,h){
		rep(x,0,w){
			if(d[y][x]!=d1[y][x])flag1 = 0;
		}
	}
	if(flag1 == 1)flag = 1;
}

int main() {
	flag = 0;
	cin>>h>>w;
	vector<string> vs;
	clr(d,0);
	rep(i,0,h){
		string s;
		cin>>s;
		rep(j,0,s.sz){
			if(s[j]=='#'){
				d[i][j] = 1;
			}
		}
	}
	rep(i,0,1<<16){
		ll dd[16];
		clr(dd,0);
		rep(j,0,16){
			if((i>>j)&1){
				dd[j]=1;
			}
		}
		f(dd);
	}
	if(flag == 1){
		cout << "Possible" << endl;
	}
	else{
		cout << "Impossible" << endl;
	}
	return 0;
}

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

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

  int ans = 1000;
  for(char target = 'a'; target <= 'z'; target++){
    int prev = -1, max_dist_i = 0;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == target){
        max_dist_i = max(max_dist_i, i - prev - 1);
        prev = i;
      }
    }
    max_dist_i = max(max_dist_i, static_cast<int>(s.size()) - prev - 1);
    ans = min(ans, max_dist_i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n;
      cin>>n;
      lint a[n+1];
      rep(i,n+1){
          cin>>a[i];
      }
      P p[n+1];
      p[n]=make_pair(a[n],a[n]);
      rep(i,n){
          p[n-i-1]=make_pair((p[n-i].first+1)/2+a[n-i-1],a[n-i-1]+p[n-i].second);
      }
      lint x=1;
      lint ans=1;
        if(p[0].first<=1&&1<=p[0].second){
            rep(i,n){
                lint y=min(x*2,p[i+1].second);
                ans+=y;
                x=y-a[i+1];
            }
            cout<<ans<<endl;
        }else{
            cout<<-1<<endl;
        }
        }
      
    
  

Measured memory_bytes: 5956
#include <iostream>
#include <cstdlib>

int get_input(void) {
    int i;
    std::cin >> i;

    if (std::cin.fail()) {
        exit(0);
    }

    return i;
}

int solve(int nol) {
    if (nol == 1) {
        return 2;
    } else {
        return solve(nol-1) + nol;
    }
}


int main(void) {
    while (true) {
        std::cout << solve(get_input()) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll n,a,b;
    ll ans=0;
    cin >> n >> a >> b;
    vector<ll> x(n);
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    for(ll i=1;i<n;i++){
        ll tmp=x[i]-x[i-1];
        if(a*tmp>b){
            ans+=b;
        }else{
            ans+=a*tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> h(N);
    for(int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    int count = 0;
    while(true){
        //初め
        int begin = -1;
        for(int i = 0; i < N; i++)
        {
            if(p[i] < h[i]){
                begin = i;
                break;
            }
        }
        if(begin == -1){
            break;
        }
        //終わり
        int end = begin;
        bool tmp = false;
        for(int i = begin; i < N; i++)
        {
            if(p[i] >= h[i]){
                end = i-1;
                tmp = true;
                break;
            }
        }
        if(!tmp){
            end = N-1;
        }
        for(int i = begin; i <= end; i++)
        {
            p[i]++;
        }
        count++;
    }
    cout << count << endl;
    
}

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

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  pair<ll, ll> p;
  for (int i=floor(sqrt(N)); i>=1; i--){
    if (N % i == 0){
      p.first = i;
      p.second = N / i;
      break;
    }
  }
  cout << (p.first + p.second - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int  sx, sy, tx, ty, i;
 
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
 
  putchar('L');
  for(i=0; i<(ty-sy)+1; i++)  putchar('U');
  for(i=0; i<(tx-sx)+1; i++)  putchar('R');
  putchar('D');
  for(i=0; i<(tx-sx); i++)  putchar('L');
  for(i=0; i<(ty-sy); i++)  putchar('D');
  for(i=0; i<(tx-sx); i++)  putchar('R');
  for(i=0; i<(ty-sy); i++)  putchar('U');
  putchar('R');
  for(i=0; i<(ty-sy)+1; i++)  putchar('D');
  for(i=0; i<(tx-sx)+1; i++)  putchar('L');
  putchar('U');
 
  putchar('\n');
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int t;
  cin>>t;
  if(t<600)
    cout<<"8";
  else if(t>=600&&t<800)
    cout<<"7";
  else if(t>=800&&t<1000)
    cout<<"6";
  else if(t>=1000&&t<1200)
    cout<<"5";
  else if(t>=1200&&t<1400)
    cout<<"4";
  else if(t>=1400&&t<1600)
    cout<<"3";
  else if(t>=1600&&t<1800)
    cout<<"2";
  else
    cout<<"1";
  return 0;
}

Measured memory_bytes: 3044
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  int N; cin >> N;
  double invA[N];
  for(int i=0; i< N; i++){
    int v;
    cin >> v;
    invA[i] = 1.0/double(v);
  }

  double ans = 0.0;
  for(int i=0; i < N; i++){
    ans += invA[i];
  }
  ans = 1.0 / ans;
  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

typedef long long ll;
struct edge {int to, cost;};
typedef pair<int, int> P;
typedef complex<double> C;

const int INF = 99999999;
const int MAX_M = 100;
const int MAX_N = 100;

//1: sweet, 0:bitter, -1:empty
int a[MAX_M][MAX_N];
int M, N;

void input() {
    scanf("%d%d", &M, &N);
    REP(i, M) {
        REP(j, N) {
            scanf("%d", &a[i][j]);
        }
    }
}

bool inside(int x, int y) {
    return x >= 0 && x < M && y >= 0 && y < N;
}

void change(int i, int j) {
    if (!inside(i, j)) return;
    if (a[i][j] == -1) return;
    a[i][j] = (a[i][j] == 0) ? 1 : 0;
}

void eat(int i, int j) {
    a[i][j] = -1;   //???????????????
    change(i+1, j); //???
    change(i, j+1); //???
    change(i, j-1); //???
}

void solve() {
    int ans = 0;

    REP(i, M) {
        //?????????????????¨??????????£?????????????
        REP(j, N) {
            if (a[i][j] != 1)
                break;
            eat(i, j);
            ans++;
            // printf("%d, %d\n", i, j);
            // REP(i, M) {
            //     REP(j, N) {
            //         printf("%d ", a[i][j]);
            //     }
            //     printf("\n");
            // }
        }
        //????????????????????¨??????????£?????????????
        RREP(j, N) {
            if (a[i][j] != 1)
                break;
            eat(i, j);
            ans++;
            // printf("%d, %d\n", i, j);
            // REP(i, M) {
            //     REP(j, N) {
            //         printf("%d ", a[i][j]);
            //     }
            //     printf("\n");
            // }
        }
        //?????£????????????????????????
        REP(j, N) {
            if (a[i][j] == 1) {
                ans++;
                // printf("%d, %d\n", i, j);
            }
            if (a[i][j] != -1) {
                eat(i, j);
            }
            // REP(i, M) {
            //     REP(j, N) {
            //         printf("%d ", a[i][j]);
            //     }
            //     printf("\n");
            // }
        }
    }

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

}

int main() {
    input();
    solve();
}

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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,count=0,c[4]={0,0,0,0};
  scanf("%d",&N);
  char s[N];
  for(int i=0;i<N;i++) scanf("%s ",&s[i]);
  for(int i=0;i<N;i++){
    if(s[i] == 'P')c[0]=1;
    else if(s[i] == 'W')c[1]=1;
    else if(s[i] == 'G')c[2]=1;
    else if(s[i] == 'Y')c[3]=1;
  }
  for(int i=0;i<4;i++){
    if(c[i]==1)count++;
  }
  if(count==3)printf("Three");
  else printf("Four");
  return 0;
}


Measured memory_bytes: 128
ans = "keyence"

s = input()
flag=0
if ans in s:
  flag=1
  print("YES")
else:
  for i in range(1,len(ans)):
    if s[:i] == ans[:i] and s[i-len(ans):] == ans[i-len(ans):]:
      flag=1
      print("YES")
      break
if flag==0:
  print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   char a,b;
   cin >> a >> b;

   if(a==b ) cout << "H" << endl;
   else cout << "D" << endl;


   return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
long long calc(long long x) {
  long long y = x / 4 * 4;
  long long res = 0;
  for (long long i = y; i <= x; i++) {
    res ^= i;
  }
  return res;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
  long long a, b;
  cin >> a >> b;
  cout << (calc(a - 1) ^ calc(b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def M(l,r):
	if l+1>=r: return 0
	if l+2==r:
		if A[l]<=A[l+1]: return 0
		A[l],A[l+1]=A[l+1],A[l]
		return 1
	m = (l+r)//2
	i=l
	j=m
	k=l
	cl=M(l,m)
	cr=M(m,r)
	c=0
	while i<m and j<r:
		if A[i]<=A[j]:
			W[k]=A[i]
			k+=1
			i+=1
		else:
			W[k]=A[j]
			k+=1
			j+=1
			c+=m-i
	while i<m:
		W[k]=A[i]
		k+=1
		i+=1
	while j<r:
		W[k]=A[j]
		k+=1
		j+=1
	for i in range(l,r): A[i]=W[i]
	return cl+cr+c

raw_input()
A=list(map(int,raw_input().split()))
W=[0]*len(A)
print(M(0,len(A)))

Measured memory_bytes: 39504
x,y = map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
print("Yes" if(x in a and y in a) else "Yes" if(x in b and y in b) else "Yes" if(x in c and y in c) else "No")

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

int main() {
    int r,g,b,n; cin >> r >> g >> b >> n;
    long ans = 0;
    for(int i = 0; i <= n/r; i ++) {
        for(int j = 0; j <= n/g; j ++) {
            int k = n-(i*r)-(j*g);
            if(k%b==0 && k>=0) ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        int dp[]=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=sc.nextInt();
        }
        for(int i=0;i<k&&i<n;i++)
        {
            dp[i]=Math.abs(a[i]-a[0]);
        }
        for(int i=k;i<n;i++)
        {
            dp[i]=Integer.MAX_VALUE;
            for(int j=i-1;j>=i-k;j--)
            {
                dp[i]=Math.min(dp[i],Math.abs(a[j]-a[i])+dp[j]);
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 50008
#include <bits/stdc++.h>
#define int long long
const int MAXN = 1e6 + 10;
using namespace std;
int prime[MAXN];
int Mark[MAXN];
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a%b);
}
bool isPrime(int n) 
{ 
 
 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int32_t main() {
	int a, b;cin >> a >> b;
	int res=gcd(a,b);
	int ans=0;
 
	
	for(int i=2;i<=sqrt(res);i++){
		if(res%i==0){
			ans++;
			while(res%i==0)res/=i;
		}
	}
	if(res>2)ans++;
	cout<<ans+1<<endl;
	
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
  	cout << a + b << '\n';
  } else {
  	cout << b - a << '\n';
  }
  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 reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    collect(B, M);
    int ACs = 0;
    rep(i,N){
        int sum = 0;
        rep(j,M){
            int a; cin >> a;
            sum += B[j]*a;
        }
        if(sum+C > 0) ACs++;
    }
    cout << ACs << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> v;
void dfs(ll a,int b){
 	v.push_back(a);
  	if(b>8)
      	return ;
  	int s = a%10;
  	dfs(a*10+s,b+1);
  	if(s!=0)
      dfs(a*10 + s - 1,b+1);
  	if(s <= 8)
      	dfs(a*10 + s + 1,b+1);
}
int main(){
 	int k,i;
  	cin>>k;
  	for(i=1;i<=9;++i)
      	dfs(i,0);
  	sort(v.begin(),v.end());
  	v.erase(unique(v.begin(),v.end()),v.end());
  	cout<<v[k-1]<<"\n";
}


Measured memory_bytes: 3444
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
# def LIST(): return list(map(int, input().split()))
def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = LIST()

l = Counter(S)
if len(l) == 3:
    print("Three")
else:
    print("Four")

Measured memory_bytes: 5148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vector<bool>used;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		used[v]=1;
		for(int i=0;i<G[v].size();i++){
			edge &e=G[v][i];
			if(used[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t
		int flow=0,f;
		while(1){
			used=vector<bool>(n,false);
			f=dfs(s,t,inf);
			if(f==0)return flow;
			flow+=f;
		}
	}
};
int main(){
	int H,W,C,M,Nw,Nc,Nm;
	while(cin>>H>>W>>C>>M>>Nw>>Nc>>Nm,H+1){
		MF mf(7+H+W*2+C*2+M);
		int s=H+M+(W+C)*2+5,t=s+1;
		int h=0,w1=H,w2=w1+W+1,c1=w2+W+1,c2=c1+C+1,m=c2+C+1;
		rep(i,H)mf.add_edge(s,i,1);
		rep(i,H)mf.add_edge(i,w1+W,1);
		rep(i,W)mf.add_edge(w1+i,w2+i,1);
		rep(i,C)mf.add_edge(w2+W,c1+i,1);
		rep(i,W)mf.add_edge(w2+i,c1+C,1);
		rep(i,C)mf.add_edge(c1+i,c2+i,1);
		rep(i,M)mf.add_edge(c2+C,m+i,1);
		rep(i,C)mf.add_edge(c2+i,m+M,1);
		rep(i,M)mf.add_edge(m+i,t,1);
		mf.add_edge(w1+W,w2+W,Nw);
		mf.add_edge(c1+C,c2+C,Nc);
		mf.add_edge(m+M,t,Nm);
		rep(i,W){
			int a;
			cin>>a;
			rep(j,a){
				int b;
				cin>>b;b--;
				mf.add_edge(h+b,w1+i,1);
			}
		}
		rep(i,C){
			int a;
			cin>>a;
			rep(j,a){
				int b;
				cin>>b;b--;
				mf.add_edge(w2+b,c1+i,1);
			}
		}
		rep(i,M){
			int a;
			cin>>a;
			rep(j,a){
				int b;
				cin>>b;b--;
				mf.add_edge(c2+b,m+i,1);
			}
		}
		cout<<mf.mf(s,t)<<endl;
	}
}

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

int main()
{
    int N;
    cin >> N;
    long long L[N + 1];

    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        L[i] = L[i - 1] + L[i - 2];
    }

    cout << L[N] << endl;

    return 0;
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (ws (make-array n :element-type 'uint32))
         (res #xffffffff))
    (dotimes (i n) (setf (aref ws i) (read)))
    (dotimes (end (+ n 1))
      (setf res
            (min res
                 (abs (- (loop for i below end sum (aref ws i))
                         (loop for i from end below n sum (aref ws i)))))))
    (println res)))

#-swank(main)


Measured memory_bytes: 19044