akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define N 100
#define INF 999999
#define LEN 1000

int n,M[N][N];
int d[N];

int Q[LEN+1];
int head = 0, tail = 0;

void enqueue(int x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

int dequeue(){
  int x;
  x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

void bfs(int s){
  int i,u,v,swap;
  enqueue(s);
  for(i = 0; i < n; i++){
    d[i] = INF;
  }
  d[s] = 0;
  while(head != tail){
    u = Q[head];
    swap = dequeue();
    for(v = 0; v < n; v++){
      if(M[u][v] == 0)continue;
      if(d[v] != INF)continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for(i = 0; i < n; i++){
    printf("%d ",i + 1);
    if(d[i] == INF) printf("%d",-1);
    else printf("%d",d[i]);
    printf("\n");
  }
  
}
 
int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);
  
  return 0;
}



Measured memory_bytes: 2108
n = int(input())
l = [0]*n
for i in range(n):
  l[i] = int(input())
l.sort()

s = sum(l)
if s%10 != 0:
  print(s)
else:
  for i in range(n):
    if l[i]%10 != 0:
      print(s-l[i])
      exit()
  else:
    print(0)
    exit()

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

int main() {
	string s, t;
	int a, b;
	string u;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u)
	{
		--a;
	}
	else
	{
		--b;
	}

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


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool exist[100010];
int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    exist[0] = true;
    rep(i, 100000) cnt[i] = 1;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(exist[x]) {
            exist[y] = true;
        }
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == 0) exist[x] = false;
    }
    int ans = 0;
    rep(i, N) ans += (exist[i]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

unordered_map < string , int > M;

string a;

int main()
{
    int n;
    cin >> n;
    while(n -- )
    {
        cin >> a;
        ++M[a];
    }
    cout << M.size() << "\n";
    return 0;
}


Measured memory_bytes: 17644
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val datX = readLine.split(" ").map(_.toInt)

    (0 to 4) foreach {i =>
      if (datX(i) == 0) println(i + 1)
    }
  }
}


Measured memory_bytes: 54564
# -*- coding: utf-8 -*-
# input
a = int(input())
if a % 11 == 0:
    print(int((a//11)*2))
elif a % 11 <= 6:
    print(int((a//11)*2+1))
elif a % 11 > 6:
    print(int((a//11)*2+2))


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int S,s,m,h;
	scanf("%d", &S);
	h = S / 3600;
	m = S % 3600/60;
	s = S % 3600 % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 1024
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  const int n=(int)s.size();
  long long a[n]={}, leftR=0, cntR=0, cntL=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      cntR++;
      leftR=i;
      cntL=0;
    }else{
      if(cntR>0){
        a[i] += cntR/2;
        a[i-1] += cntR/2+cntR%2;
      }
      cntL++;
      a[leftR+cntL%2]++;
      cntR=0;
    }
  }
  for(int i=0;i<n;i++){
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}


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

int main(){
	string s;
  	cin >> s;
  	int ans = 0;
  	for(int i=0; i<4; i++){
    	if(s[i] == '+'){
        	ans++;
        }else{
        	ans--;
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200010
const ll mod=1e9+7;
ll dp[maxn][2]={0};
int n,a[maxn],b[maxn],pre[maxn],cnt=0;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        if(a[i]!=a[i-1])
            b[++cnt]=a[i];
    dp[1][0]=1;
    pre[b[1]]=1;
    for(int i=2;i<=cnt;i++)
    {
        int pos=pre[b[i]];
        dp[i][0]=(dp[i-1][1]+dp[i-1][0])%mod;
        dp[i][1]=(dp[pos][1]+dp[pos][0])%mod;
        pre[b[i]]=i;
    }
    printf("%lld\n",(dp[cnt][1]+dp[cnt][0])%mod);
   return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    val length1 = scan.nextInt()
    val length2 = scan.nextInt()
    val area = length1*length2
    val perim = 2*(length1+length2)
    println("${area} ${perim}")
}


Measured memory_bytes: 25640
<?php
$start = microtime(true);
list($n) = ints();
$k = 26;
$c = ints();
$last = array_fill(0, $k, 0);
for ($i = 1; $i <= $n; ++$i) {
    $s[$i] = ints();
    $max = PHP_INT_MIN;
    for ($p = 0; $p < $k; ++$p) {
        $ts = ($score[$i - 1] ?? 0) + $s[$i][$p];
        for ($q = 0; $q < $k; ++$q) {
            if ($p === $q) continue;
            $ts -= $c[$q] * ($i - $last[$q]);
        }
        if ($ts > $max) {
            $max = $ts;
            $maxp = $p;
        }
    }
    $score[$i] = $max;
    $ans[$i] = $maxp + 1;
    $last[$maxp] = $i;
}
$score = $score[365];
while (true) {
    for ($i = 365; $i >= 1; --$i) {
        for ($p = 1; $p <= $k - 1; ++$p) {
            $anst = $ans;
            $anst[$i] = ($ans[$i] + $p) % 26;
            $scoret = calcScore($anst);
            $diff = $scoret - $score;
            if ($diff > 0) {
                $ans = $anst;
                $score = $scoret;
                break;
            }
        }
        $now = microtime(true);
        if ($now - $start > 1.9) break 2;
    }
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
function calcScore($ans)
{
    global $c, $s;
    $last = array_fill(0, 26, 0);
    $score[0] = 0;
    for ($i = 1; $i <= 365; ++$i) {
        $score[$i] = ($score[$i - 1] ?? 0) + $s[$i][$ans[$i]];
        $last[$ans[$i]] = $i;
        for ($q = 0; $q < 26; ++$q) {
            $score[$i] -= $c[$q] * ($i - $last[$q]);
        }
    }
    return $score[365];
}


Measured memory_bytes: 16888
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll MOD=1000000007;
int main(){
    ll N,K;cin>>N>>K;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    vector<ll>B;
    vector<ll>C;
    rep(i,N){
        if(A[i]<0){
            C.push_back(A[i]);
        }
        else{
            B.push_back(A[i]);
        }
    }
    ll ans=1;
    sort(C.begin(),C.end());
    sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    if(K%2==1&&B.size()==0){
        reverse(C.begin(),C.end());
        rep(i,K){
            ans=(ans*C[i])%MOD;
        }
        if(ans<0){
            while(ans<0){
                ans+=MOD;
            }
        }
        cout<<ans%MOD<<endl;
    }
    else if(K%2==0){
        K=K/2;
        vector<ll>D;
        ll F=1;
        rep(i,B.size()){
            if(i%2==0&&i+1<B.size()){
                D.push_back(B[i]*B[i+1]);
            }
        }
        if(B.size()%2!=0){
            F*=B[B.size()-1];
        }
        rep(i,C.size()){
            if(i%2==0&&i+1<C.size()){
                D.push_back(C[i]*C[i+1]);
            }
        }
        if(C.size()%2!=0){
            F*=C[C.size()-1];
            D.push_back(F);
        }
        sort(D.begin(),D.end());
        reverse(D.begin(),D.end());
        rep(i,K){
            ans=(ans*(D[i]%MOD))%MOD;
        }
        if(ans<0){
            while(ans<0){
                ans+=MOD;
            }
        }
        cout<<ans%MOD<<endl;
    }
    else{
        K=K-1;
        ans*=B[0]%MOD;
        vector<ll>G;
        for(int i=1;i<B.size();i++){
            G.push_back(B[i]);
        }
        sort(G.begin(),G.end());
        reverse(G.begin(),G.end());
        K=K/2;
        vector<ll>D;
        ll F=1;
        rep(i,G.size()){
            if(i%2==0&&i+1<G.size()){
                D.push_back(G[i]*G[i+1]);
            }
        }
        if(G.size()%2!=0){
            F*=G[G.size()-1];
        }
        rep(i,C.size()){
            if(i%2==0&&i+1<C.size()){
                D.push_back(C[i]*C[i+1]);
            }
        }
        if(C.size()%2!=0){
            F*=C[C.size()-1];
            D.push_back(F);
        }
        sort(D.begin(),D.end());
        reverse(D.begin(),D.end());
        rep(i,K){
            ans=(ans*(D[i]%MOD))%MOD;
        }
        if(ans<0){
            while(ans<0){
                ans+=MOD;
            }
        }
        cout<<ans%MOD<<endl;
    }
}

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

int main(){
	int n,m;cin>>n>>m;
	bool ans=false;
	bool from_1[n+5]={false};
	bool to_n[n+5]={false};

  for(int i=0;i<m;++i){
    int a,b;cin>>a>>b;
    if(a==1){
      from_1[b]=true;
    }
    if(b==n){
      to_n[a]=true;
    }
  }
  for(int i=0;i<=n;++i){
    if(from_1[i]&&to_n[i])ans=true;
  }

  if(ans)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    ll n, k;
    cin >> n >> k;
    n = n % k;
    cout << min(n, k - n) << endl;
}

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

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import collections

def main():
    _ = int(input())
    D = collections.defaultdict(int)
    for a in list(map(int, input().split())):
        D[a] += 1
    ans = 0
    for k,v in D.items():
        if k > v:
            ans += v
        elif k < v:
            ans += v-k
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> food(m);

	int k;
	int num;
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> num;
			food.at(num - 1)++;
		}
	}
	
	int count;
	for (int i = 0; i < food.size(); i++) {
		if (food.at(i) == n) {
			count++;
		}
	}

	cout << count++ << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int n;
	while (cin >> n, n) {
		REP(i, n) {
			int m, e, j;
			scanf("%d %d %d", &m, &e, &j);
			
			int sum = m + e + j;
			int sum2 = m + e;
			
			int grade = 2;
			if (sum >= 150 && (m >= 80 || e >= 80)) grade = 1;
			if (sum >= 210) grade = 1;
			if (sum >= 240) grade = 0;
			if (sum2 >= 180) grade = 0;
			if (m == 100 || e == 100 || j == 100) grade = 0;
			
			printf("%c\n", grade + 'A');
		}
	}
	return 0;
}

Measured memory_bytes: 3128
import java.util.Scanner;

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

	int[] n = new int[101];
	int[] c = new int[3];
	for(int i = 0; i < 3; i++){
	    c[i] = scan.nextInt();
	    n[c[i]]++;
	}

	int count = 0;
	for(int i = 1; i < 101; i++){
	    if(n[i] != 0){
		count++;
	    }
	}

	System.out.println(count);
    }
}


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

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  for (int i = 0; i < N; ++i) {
    cin >> t[i];
  }
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    ans += min(t[i + 1] - t[i], T);
  }
  ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 1024
class dsu():
    n=1
    parent_or_size=[-1 for i in range(n)]
    def __init__(self,N):
        self.n=N
        self.parent_or_size=[-1 for i in range(N)]
    def merge(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        x=self.leader(a)
        y=self.leader(b)
        if x==y:
            return x
        if (-self.parent_or_size[x]<-self.parent_or_size[y]):
            x,y=y,x
        self.parent_or_size[x]+=self.parent_or_size[y]
        self.parent_or_size[y]=x
        return x
    def same(self,a,b):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n)
        return self.leader(a)==self.leader(b)
    def leader(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        if (self.parent_or_size[a]<0):
            return a
        self.parent_or_size[a]=self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]
    def size(self,a):
        assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n)
        return -self.parent_or_size[self.leader(a)]
    def groups(self):
        leader_buf=[0 for i in range(self.n)]
        group_size=[0 for i in range(self.n)]
        for i in range(self.n):
            leader_buf[i]=self.leader(i)
            group_size[leader_buf[i]]+=1
        result=[[] for i in range(self.n)]
        for i in range(self.n):
            result[leader_buf[i]].append(i)
        result2=[]
        for i in range(self.n):
            if len(result[i])>0:
                result2.append(result[i])
        return result2
def main():
    import sys
    sys.setrecursionlimit(311111)
    # import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    n,m  = ina()
    tmp = dsu(n)
    for _ in range(m):
        x,x1 = ina()
        tmp.merge(x-1,x1-1)
    print(len(tmp.groups())-1)

    
    



    


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()


Measured memory_bytes: 107756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n, k; cin >> n >> k;
    int cnt = 1;
    n -= k;
    while(n > k-1) {
        cnt++;
        n -= k - 1;
    }
    if(n != 0) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int a[maxn], dp[maxn];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    REP(i, n) scanf("%d", a + i);
    memset(dp, inf, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i >= j) {
                dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define SWAP(x, y) ((x) += (y), (y) = (x) - (y), (x) -= (y))
#define PARENT(x) (x / 2)
#define LEFT(x) (2 * x)
#define RIGHT(x) (2 * x + 1)

long long int heap_size, a[100000000];

void maxHeapify(long long int *a,long long int i){
  long long int l = LEFT(i), r = RIGHT(i), largest;
  if(l <= heap_size && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= heap_size && a[r] > a[largest]) largest = r;
  if(largest != i){
    SWAP(a[i], a[largest]);
    maxHeapify(a, largest);
  }
  return;
}

void heapIncreaseKey(long long int *a, long long int i, long long int key){
  if(key < a[i]);
  a[i] = key;
  while(i > 1 && a[PARENT(i)] < a[i]){
    SWAP(a[i], a[PARENT(i)]);
    i = PARENT(i);
  }
  return;
}

void maxHeapInsert(long long int *a,long long int key){
  heap_size++;
  a[heap_size] = -100000;
  heapIncreaseKey(a, heap_size, key);
  return;
}

long long int heapExtractMax(long long int *a){
  if(heap_size < 1);
  long long int  max = a[1];
  a[1] = a[heap_size];
  heap_size--;
  maxHeapify(a, 1);
  return max;
}

int main(){
  long long int key, i, j;
  char op[10];

  while(scanf("%s", op) && strcmp(op, "end") != 0){
    if(op[0] == 'i'){
      scanf("%lld", &key);
      maxHeapInsert(a, key);
    }else if(op[0] == 'e')
      printf("%lld\n", heapExtractMax(a));
  }
  return 0;
}

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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
//#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

#define MOD 998244353


int n,s,a,dp[3001][3001],ans;

signed main() {
    cin >> n >> s;
    dp[0][0] = 1;
    rep1(i,n) {
        cin >> a;
        rep(j,s+1) {
            int d = 0;
            if (j >= a) d = dp[i-1][j-a]%MOD;
            dp[i][j] = (dp[i-1][j] + d)%MOD;
        }
        dp[i][0]++;
        dp[i][0] = dp[i][0]%MOD;
        if (a <= s) {
            //ans += dp[i-1][s-a];
            //rep11(j,i) ans += dp[j][s-a];
        }
        ans = (ans+dp[i][s])%MOD;
    }
    cout << ans%MOD << endl;
}

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

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

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 1e18+1
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
ll arr[52][4];
ll tmp[52];
ll n,m,q,ans;

void dfs(ll id,ll v)
{
    if(id>n)
    {
        ll ct=0;
        fr(i,0,q)
        {
            if(tmp[arr[i][1]]-tmp[arr[i][0]]==arr[i][2])
            {
                ct+=arr[i][3];
            }
        }
        ans=max(ans,ct);
    }
    else
    {
        fr(j,v,m+1)
        {
            tmp[id]=j;
            dfs(id+1,j);
            //tmp.pop_back();
        }
    }
}
void solve()
{
    
    cin>>n>>m>>q;
    
    fr(i,0,q)
    {
        cin>>arr[i][0];
        cin>>arr[i][1];
        cin>>arr[i][2];
        cin>>arr[i][3];
    }
    dfs(1,1);
    cout<<ans<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long llint;
const llint MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<llint> r(n + 2);
  for (int i = 0; i <= n; i++) r[i + 1] += r[i] + i + 1;
  llint ans = 0;
  for (int i = k; i <= n; i++) {
    llint mx = r[n] - r[n - i];
    llint mn = r[i - 1];
    ans += mx - mn + 1;
    ans %= MOD;
  }
  cout << (ans + 1) % MOD << endl;

  return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> x(n);
	REP(i,n) cin>>x[i];
	ll l;
	cin>>l;
	vector<vector<ll>> dbl(n,vector<ll>(21));
	REP(i,n) {
		auto ite=upper_bound(ALL(x),x[i]+l);
		ite--;
		dbl[i][0]=(int)(ite-x.begin());
	}
	FOR(i,1,21) {
		REP(j,n) {
			dbl[j][i]=dbl[dbl[j][i-1]][i-1];
		}
	}
	ll q;
	cin>>q;
	REP(roop,q) {
		ll a,b;
		cin>>a>>b;
		a--;
		b--;
		if(a>b) swap(a,b);
		ll lb=0,ub=n;
		while(ub-lb>1) {
			ll mid=(ub+lb)/2;
			ll buf=mid;
			ll crt=a;
			REP(i,21) {
				if(buf%2==1) crt=dbl[crt][i];
				buf/=2;
			}
			if(crt<b) lb=mid;
			else ub=mid;
		}
		cout<<lb+1<<endl;
	}
}


Measured memory_bytes: 21120
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans=a-b;
    if(k%2==1) ans*=-1;
    if(abs(ans)>(ll)1e18) cout << "Unfair" << endl;
    else cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<string> S(M);
    vector<bool> isAC(N, false);
    vector<int>  WAcount(N, 0);
    int AC = 0, WA = 0;
    for(int i = 0; i < M; i++) {
        cin >> p.at(i) >> S.at(i);
        if(!isAC.at(p.at(i) - 1)) {
            if(S.at(i) == "AC") {
                AC++;
                isAC.at(p.at(i) - 1) = true;
            } else {
                WAcount.at(p.at(i) - 1)++;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        if(isAC.at(i)) {
            WA += WAcount.at(i);
        }
    }
    cout << AC << ' ' << WA << endl;
}

Measured memory_bytes: 6528
import java.util.*;

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();
        for(int i = 0; i < 10; i++) {
            x = r * x - d;
            System.out.println(x);
        }
    } 
}

Measured memory_bytes: 20556
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>

int main(){
    int N;
    std::cin >> N;
    char t;
    std::set<char> s;
    for(int i=0;i<N;i++){
        std::cin >> t;
        s.insert(t);
    }
    if(s.size()==4){
        std::cout << "Four" << std::endl;
    }else{
        std::cout << "Three" << std::endl;
    }
}

Measured memory_bytes: 256
//
// Created by dina on 05/07/20.
//

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

int main(){
    int n; cin >> n;
    int rem = n%1000;
    if(rem == 0) cout << 0 << "\n";
    else cout << 1000 - rem << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
ll x;
int n, m;
bool mat[10][10];
int ans;
void dfs(int num, int cur, bool* vis) {
	if (num == n) {
		ans++;
		return;
	}
	for (int i = 1; i <= n; ++i) {
		if (!vis[i] && mat[cur][i]) {
			vis[i] = true;
			dfs(num+1, i, vis);
			vis[i] = false;
		}
	}
}
int main() {
	cin>>n>>m;
	memset(mat, false, sizeof(mat));
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin>>a>>b;
		mat[a][b] = mat[b][a]= true;
	}
	ans=0;
	bool vis[10];
	memset(vis, false, sizeof(vis));
	vis[1] = true;
	dfs(1, 1, vis);
	vis[1]= false;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
ll col[N],k;
ll vis[N];
std::vector<ll> a[N];
void dfs(ll node,ll par)
{
	vis[node]=1;
	ll c;
		if(par==-1)
			c=1;
		else
			c=2;
		for(auto i:a[node])
		{
			if(!vis[i])
			{
				col[i]=k-c;
				c++;
			}
		}
	for(auto i:a[node])
	if(!vis[i])
	dfs(i,node);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n>>k;
        for(int i=0;i<n-1;i++)
        {
        	ll b,c;
        	cin>>b>>c;
        	a[b].pb(c);
        	a[c].pb(b);
        }
        col[1]=k;
        dfs(1,-1);
        ll ans=1;
        for(int i=1;i<=n;i++)
        {
        	ans=(ans*col[i])%hell;
        }
        cout<<ans;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll n, a, b;
    in3(n, a, b);
    ll ans = n / (a + b) * a;
    ll tmp = n - n / (a + b) * (a + b);
    if (tmp < a)
    {
        ans += tmp;
    }
    else
    {
        ans += a;
    }
    out(ans);
}

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

int under(int v,int m){
	int ret=0;
	while(ret+v<=m)ret+=v;
	return ret;
}

int main(){
	int n,m;
	while(cin>>n>>m&&(n||m)){
		vector<pair<pii,int>> vec;	//????????? ????\??????????????????£??????????????\???????????????
		vector<int> v(n);
		rep(i,n)cin>>v[i];
		
		rep(i,n){
			int new_time=under(v[i],m), new_diffi=v[i], new_pos=i+1;
			vec.push_back(make_pair(pii(new_time,new_diffi),new_pos));
		}
		sort(all(vec));
		if(vec[0].first==vec[1].first)cout<<n<<endl;
		else cout<<vec[0].second<<endl;
	}
}

Measured memory_bytes: 3128
N=int(input()) 
s = input()


def kensaku(n1,n2,n3,s):
  i2 = -1
  i3 = -1
  i1 = s.find(str(n1))
  if i1 >= 0:
    i2 = s.find(str(n2),i1+1)
    if i2 >0:
      i3 = s.find(str(n3),i2+1)
  return int(i3>0)

count = 0

for n1 in range(10):
  for n2 in range(10):
    for n3 in range(10):
      count = count +kensaku(n1,n2,n3,s)
      
print(count)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans=0;
    ll n;
    cin>>n;
    rep(i,1,n+1){
        if(i%3 && i%5)ans+=i;
    }
    cout<<ans<<'\n';
    return 0;   
}   

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

int main() {
	int N;
	int L;
	int app[200] = {};
	int sum = 0;
	int sum2 = 0;
	int small = -500;
	int num = 0;


	std::cin >> N;
	std::cin >> L;
	for (int i = 0; i < N; i++) {
		app[i] = L + (i + 1) - 1;
		sum += app[i];
		if (abs(small) > abs(app[i])) {
			small = app[i];
		}
	}

	sum2 = sum - small;

	std::cout << sum2 << std::endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



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


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vi a(n);
	int c = 0;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
		if(i%2==0 and a[i]%2==1)
		{
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

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

#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

struct Monster {
  ll x, h;
  bool operator< (const Monster &other) const {
    return x < other.x;
  }
};

#define MAX_X 1000000000LL
#define INFTY 1e9
ll N, D, E;
vector<Monster> M;

// 1)
// 0 1 2 3 4 5 6 7 8 9
//   2       4       2
//       - - - o - - -
//   - - - o - - -
//
// 2)
// 1 2 3 4 5 6 7 8 9
// 5 4 3 2 1 2 3 4 5
// - - - - o - - - -
// - - - - o - - - -
// - - - - o - - - -
// - - - - o - - - -
// - - - - o - - - -
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// 3   3   3   3   3     3     3     3
// - - o - -
// - - o - -
// - - o - -

vector<ll> A, B;

void init() {
  // Nを2の累乗に補正
  ll n = 1;
  while (n < N) n *= 2;
  N = n;
  A = vector<ll>(N*2-1, 0);
  B = vector<ll>(N*2-1, 0);
}


void addRec(ll a, ll b, ll val, ll n, ll l, ll r) {
  // a l r b
  if (a <= l && r <= b) {
    A.at(n) += val;
    return;
  }

  // l  a  r    b
  if (l < b && a < r) {
    B.at(n) += (min(b, r) - max(a, l)) * val;
    addRec(a, b, val, n*2+1, l, (l+r)/2);
    addRec(a, b, val, n*2+2, (l+r)/2, r);
  }
}

void add(ll a, ll b, ll val) {
  addRec(a, b, val, 0, 0, N);
}

ll findRec(ll x, ll y, ll n, ll l, ll r) {
  // i)        l      r    x   y
  // i)  x   y l      r
  if (r <= x || y <= l) return 0;
  // iii)  x    l     r    y
  if (x <= l && r <= y) {
    return A.at(n) * (r - l) + B.at(n);
  }
  // iv)   x    l    y   r
  ll res = (min(y, r) - max(x, l)) * A.at(n);
  res += findRec(x, y, n*2+1, l, (l+r)/2);
  res += findRec(x, y, n*2+2, (l+r)/2, r);
  return res;
}

ll find(ll x, ll y) {
  return findRec(x, y, 0, 0, N);
}

void dumpRec(ll n, int depth) {
  if (n >= A.size()) return;
  for (int i=0;i<depth;i++) cout << "\t";
  cout << "(" << n << ", " << A.at(n) << ", " << B.at(n) << ")" << endl;
  dumpRec(n*2+1, depth+1);
  dumpRec(n*2+2, depth+1);
}

void dump() {
  cout << "====== dump =======" << endl;
  dumpRec(0, 0);
}


void input() {
  cin >> N >> D >> E;
  ll x, h;
  for (int i=0; i<N; i++) {
    cin >> x >> h;
    M.push_back({ x, h });
  }
}

void solve() {
  init();

  sort(M.begin(), M.end());
  ll total = 0;

  // 10^5
  for (ll i=0; i<M.size(); i++) {
    auto &m = M.at(i);
    // log{10^5}
    ll h = m.h - find(i, i+1);
    if (h <= 0) continue;
    ll count = ceil((double)h / E);
    total += count;
    ll max_x = min(m.x + 2*D, MAX_X);
    ll max_j = upper_bound(M.begin()+i, M.end(), (Monster){ max_x, 0 }) - M.begin();
    add(i, max_j, count*E);
  }

  cout << total << endl;
}

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


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

using namespace std;

typedef long long LL;

const int maxn=3005;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;

struct Question{
	int l,r;
}q[maxn];

LL C[maxn][maxn],dp[maxn][maxn];
int sum[maxn];
char s[maxn];
int n,m;

void pre_C(){
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	pre_C();
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+s[i]-'0';
	for(int i=1;i<=m;i++){
		scanf("%d%d",&q[i].l,&q[i].r);
		if(q[i].r<=q[i-1].r)m--,i--;
	}
	q[m+1].l=n+1;q[m+1].r=n+1;
	sum[n+1]=sum[n];
	dp[1][sum[q[1].r]-sum[q[1].l-1]]=1;
	for(int i=1;i<=m;i++){
		if(q[i].r<q[i+1].l){
			int len=q[i].r-q[i].l+1;
			for(int j=0;j<=len;j++){
				dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]+=dp[i][j]*C[len][j]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]%=MOD;
			}
		}
		else{
			int LEN=q[i].r-q[i].l+1;
			int len=q[i].r-q[i+1].l+1;
			int pre=q[i+1].l-q[i].l;
			for(int j=0;j<=LEN;j++)
				for(int k=max(0,j-pre);k<=j&&k<=len;k++){
					dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]+=dp[i][j]*C[pre][j-k]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]%=MOD;
				}
		}
	}
	printf("%lld\n",dp[m+1][0]);
	return 0;
}

Measured memory_bytes: 104832
#include<iostream>
#include<string>
#include<map>
#define int long long int

using namespace std;

signed main(){

    int H, W, i, j;
    char C[100][100], ANS[200][200];

    cin >> H >> W;

    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){

            cin >> C[i][j];
            if(C[i][j] == '*'){
                ANS[2*i][j] = '*';
                ANS[2*i + 1][j]= '*';
            }else{
                ANS[2*i][j] = '.';
                ANS[2*i + 1][j] = '.';
            }
        }
    }

    for(i = 0; i < 2*H; i++){
        for(j = 0; j < W; j++){
            cout << ANS[i][j];
        }

        cout << endl;
    }

    return 0;
}



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

int main() {
  int n, a[100];
  int count = 0;
  int mini;

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

  for (int i = 0; i < n; i++) {
    mini = i;

    for (int j = i; j < n; j++) {
      if (a[j] < a[mini]) {
        mini = j;
      }
    }

    if (a[i] != a[mini]) {
      swap(a[i], a[mini]);
      count++;
    }
  }

  for (int i = 0; i < n - 1; i++){
    cout << a[i] << ' ';
  }
  cout << a[n - 1] << endl;
  cout << count << endl;

  return 0;
}

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

using namespace std;

#define ll                     long long int
#define endl                   '\n'

static const int maxn = 2e5 + 5;

ll Lcm(ll a, ll b)
{
      ll gcd = __gcd(a, b);
      ll ans = a / gcd * b;
      return ans;
}

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cout << fixed << setprecision(8);

      //freopen("in.txt", "r", stdin);

      int n;
      cin >> n;
      vector <ll> arr;
      ll lcm = 0;
      for (int i = 0; i < n; i++)
      {
            ll x;
            cin >> x;
            arr.emplace_back(x);
            if (lcm == 0)
            {
                  lcm = x;
                  continue;
            }
            lcm = Lcm(x, lcm);
      }
      ll sum = 0;
      for (ll x : arr) sum += lcm / x;
      double ans = (double)lcm / (double)sum;
      cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	string s,t;
	cin>>s>>t;
	ll count=0;
	ll len=s.length();
	for(ll i=0;i<len;i++){
		if(s[i]==t[i]) count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		System.out.println(a+a*a+a*a*a);
	}
}

Measured memory_bytes: 35612
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

bool anko(map<int, int> mii){
    rep(i,10){
        if(mii[i] > 0 && mii[i + 1] > 0 && mii[i + 2] > 0){
            mii[i]--; mii[i + 1]--; mii[i + 2]--;
            i--;
            continue;
        }
    }
    range(i,1,10) mii[i]%=3;
    range(i,1,10) if(mii[i] != 0) return false;
    return true;
}

bool jun(map<int, int> mii){
    range(i,1,10) mii[i]%=3;
    rep(i,10){
        if(mii[i] > 0 && mii[i + 1] > 0 && mii[i + 2] > 0){
            mii[i]--; mii[i + 1]--; mii[i + 2]--;
            i--;
            continue;
        }
    }
    range(i,1,10) if(mii[i] != 0) return false;
    return true;
}

bool solve(map<int, int> mii, int a){
    mii[a]-=2;
    if(anko(mii) || jun(mii)) return true;
    else return false;
}

bool check(map<int, int> mii, int a){
    mii[a]++;
    range(i,1,10){
        if(mii[i] >= 2){ //???????????????????????????????????¨??¢?´¢
            if(solve(mii, i)){
                return true;
            }
        }
    }
    return false;
}

int main(){
    string str;
    while(cin >> str){
        bool c = false;
        map<int ,int> mii;
        rep(i, str.size()) mii[str[i] - '0']++;
        range(i,1,10){
            if(mii[i] == 4) continue; //????????°??????????????\???????????????
            if(check(mii, i)){
                if(c) cout << ' ';
                cout << i;
                c = true;
            }
        }
        if(not c) cout << 0;
        cout << endl;
    }
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner kbScanner = new Scanner(System.in);
		int longth = kbScanner.nextInt();
		int side = kbScanner.nextInt();
		
		int area = longth * side;
		int length = 2 * (longth + side);
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 26036
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	int n, k, x, y;cin >> n >> k >> x >> y;
	int ans = 0;
	for(int i = 0; i < min(n, k);i++)ans += x;
	n -= min(n, k);
	for(int i = 0; i < n;i++)ans += y;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7;
ll dp[100][10005],d,ans,x;
string s;

int main()
{jizz
	dp[0][0]=1;
	cin >> s >> d;
	for(int i=1;i<s.size();++i)
		for(int k=0;k<10;++k)
			for(int j=0;j<d;++j)
				dp[(j+k)%d][i]=(dp[j][i-1]+dp[(j+k)%d][i])%MOD;
	for(int i=0;i<s.size();x=(x+s[i]-'0')%d,++i)
		for(int j=0;j+'0'<s[i];++j)
			ans=(ans+dp[(d-(x+j)%d)%d][s.size()-i-1])%MOD;
	cout << (ans+(x==0)-1+MOD)%MOD << "\n";
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int n, a[1000020];
long long z, s;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] > 0) {
			s += a[i];
		} else {
			z += s / 2;
			s = a[i];
		}
	}
	printf("%lld\n", z + s / 2);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(a.at(i)==a.at(i+1)){cnt++;}
  }
  if(cnt==0){cout<<"Good"<<endl;}
  else{cout<<"Bad"<<endl;}
}


Measured memory_bytes: 256
import sys
from sys import stdin
input = stdin.readline

class BinaryTreeNode:
    def __init__(self, node):
        self.node = node
        self.left = None
        self.right = None

def Insert(parent, child):
    if parent.node > child.node:
        if parent.left != None:
            Insert(parent.left, child)
        else:
            parent.left = child
    else:
        if parent.right != None:
            Insert(parent.right, child)
        else:
            parent.right = child

IN_RESULT = []
def Inorder(root):
    if root.left == None:
        IN_RESULT.append(str(root.node))
        if root.right != None:
            Inorder(root.right)
    else:
        Inorder(root.left)
        IN_RESULT.append(str(root.node))
        if root.right != None:
            Inorder(root.right)
        else:
            pass
        
PRE_RESULT = []
def Preorder(root):
    PRE_RESULT.append(str(root.node))
    if root.left != None:
        Preorder(root.left)
    else:
        pass
    
    if root.right != None:
        Preorder(root.right)
    else:
        pass
    
    

n = int(input())


command = input()
if command[0] == "i":
    root = BinaryTreeNode(int(command[7:]))

for _ in range(n-1):
    command = input()
    if command[0] == "i":
        child = BinaryTreeNode(int(command[7:]))
        Insert(root, child)
        
    
    else:
        Inorder(root)
        Preorder(root)
        print(" "+" ".join(IN_RESULT))
        print(" "+" ".join(PRE_RESULT))
        IN_RESULT = []
        PRE_RESULT = []


Measured memory_bytes: 178000
N = int(input())
works = [list(map(int, input().split())) for i in range(N)]

sorted_works = sorted(works, key=lambda x: (x[1], x[0]))

atime = 0
for time, dead in sorted_works:
  atime += time
  if atime > dead:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 67892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        for(int i=3;i<=n;i++){
            if(check(i)){
                System.out.print(" "+i);
            }
        }
        System.out.print("\n");
    }
    public static boolean check(int n){
        if(n%3==0){
            return true;
        }else{
            while(n>0){
                if(n%10==3){
                    return true;
                }
                n = n /10;
            }
            return false;
        }
    } 
}

Measured memory_bytes: 26620
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (Math.abs(a-c) <= d)
			System.out.println("Yes");
		else if (Math.abs(a-b) <= d && Math.abs(c-b) <= d) {
				System.out.println("Yes");
		}
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 21204