akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	int a,b,n;
	scanf("%d%d%d",&n,&a,&b);
	a--;b--;
	int cur=0;
	while(1){
		if(cur%2==0){
			if(a+1<b){
				a++;
			}else{
				a--;
				if(a<0){printf("Borys\n");return 0;}
			}
		}else{
			if(b-1>a){
				b--;
			}else{
				b++;
				if(b>=n){printf("Alice\n");return 0;}
			}
		}
		cur++;
	}
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace ABC131B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nl = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int res = 0;
            if (nl[1]>=0)
            {
                for (int i = 1; i < nl[0]; i++)
                {
                    res += nl[1] + (i + 1) - 1;
                }
            }
            else
            {
                if (Math.Abs(nl[0])> Math.Abs(nl[1]))
                {
                    for (int i = 0; i < nl[0]; i++)
                    {
                        res += nl[1] + (i + 1) - 1;
                    }
                }
                else
                {
                    for (int i = 0; i < nl[0]-1; i++)
                    {
                        res += nl[1] + (i + 1) - 1;
                    }
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
//#include<bits/extc++.h> inavilable in dev-cpp
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define me(i,k) memset(i,k,sizeof(i))
#define fr1(a,n) for(int a=1;a<=(n);a++)
#define frab(i,a,b) for(int i=(a);i<(b);i++)
#define fr0(i,n) for(int i=0;i<(n);i++)
#define trav(a,n) for(auto& a : n)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const ll modn=1000000007;
 
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h[2],k[2],a,b,c,d,i,Hc,Kc;
	for(i=0;i<2;i++){
		scanf("%d",&h[i]);
	}
	for(i=0;i<2;i++){
		scanf("%d",&k[i]);
	}
	scanf("%d %d %d %d",&a,&b,&c,&d);
	Hc=(h[0]*a+h[1]*b)+(h[0]/10*c)+(h[1]/20*d);
	Kc=(k[0]*a+k[1]*b)+(k[0]/10*c)+(k[1]/20*d);
	if(Hc<Kc){
		printf("kenjiro\n");
	}
	if(Hc>Kc){
		printf("hiroshi\n");
	}
	if(Hc==Kc){
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2604
N=int(input())
l=[]
for i in range(N):
  l.append(int(input()))
l_max=max(l)
i=l.index(l_max)
if i==0:
  l1=l[1:]
  print(max(l1))
  for a in range(N-1):
    print(l_max)
elif i==N:
  l1=l[:N]
  for a in range(N-1):
    print(l_max)
  print(max(l1))
else:
  l1=l[:i]+l[i+1:]
  for a in range(i):
    print(l_max)
  print(max(l1))
  for a in range(N-i-1):
    print(l_max)

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

using namespace std;

int main(){
	string n;
	
	cin >> n;
	
	for(int i=0; i<3; i++){
		if(n[i]=='1')	cout << '9';
		if(n[i]=='9')	cout << '1';
	}
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n,m,l,i,j,k;
	scanf("%d %d %d", &n, &m, &l);
	
	long A[n][m],B[m][l],C[n][l];
	for(i = 0; i < n; i++) {
		for(j = 0; j < m; j++) {
			scanf("%ld", &A[i][j]);
		}
	}
	for(i = 0; i < m; i++) {
		for(j = 0; j < l; j++) {
			scanf("%ld", &B[i][j]);
		}
	}
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			C[i][j] = 0;
			for(k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(i = 0; i < n; i++) {
		for(j = 0; j < l; j++) {
			printf("%ld",C[i][j]);
			if(j != l-1) {
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int res = a * x + b * y;
  res = min(res, (c * 2) * max(x, y));
  res = min(res, min(x, y) * 2 * c + a * (x - min(x,y)) + b * (y - min(x, y)));
  cout << res << endl;
  return 0;
} 

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int n, k;
int V[50];

int solve(int take) {
    deque<int> q;
    inc(i, 0, n){
        q.push_back(V[i]);
    }

    int anss = 0;

    inc(i, 0, take+1){
        vector<int> v;
        deque<int> dq = q;
        int a = i;
        int b = take-i;
        while(dq.size() && a > 0){
            v.pb(dq.front());
            dq.pop_front();
            a--;
        }

        while(dq.size() && b > 0){
            v.pb(dq.back());
            dq.pop_back();
            b--;
        }

        sort(v.begin(), v.end());
        int m = v.size();
        int ans = 0;
        int res = k-take;
        inc(i, 0, m){
            if(v[i] < 0 && res > 0){
                res--;
                continue;
            }
            ans += v[i];
        }

        anss = max(ans, anss);
    }

    return anss;
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n >> k;
    inc(i, 0, n){
        cin >> V[i];
    }

    int ans = 0;
    inc(i, 0, k+1){
        ans = max(ans, solve(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# Aizu Problem 0030: Sum of Integers
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def dfs(pos, t, sum):
    global cnt
    if t == n:
        if sum == s:
            cnt += 1
        return
    if pos > 9:
        return
 
    dfs(pos+1, t, sum)
    dfs(pos+1, t+1, sum + pos)
 
 
while True:
    n, s = [int(_) for _ in input().split()]
    if n == s == 0:
        break
    cnt = 0
    dfs(0, 0, 0)
    print(cnt)
    

Measured memory_bytes: 7764
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define fi first
#define se second
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline ll abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
const ll inf=(1LL<<62);
const ll MOD=(1e9)+7;
const ll mod=998244353;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;

  cin >> s;
  if (s == "RRR") {
    cout << 3;
  }else if (s == "RRS" || s == "SRR") {
    cout << 2;
  }else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
    cout << 1;
  }else {
    cout << 0;
  }
  cout << "\n";
  return 0;
}
 

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+7;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
map<int,int>p;
int a[100010];
int main(){
//    freopen("out.txt","r",stdin);
//    freopen("outt.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        p[a[i]%a[i-1]]=1;
    }
    if(k>a[n-1]) return 0*puts("IMPOSSIBLE");
    for(int i=0;i<n;i++){
        if(a[i]==k) return 0*puts("POSSIBLE");
        else if(a[i]>k){
            int g=a[i]-k;
            for(int j=1;j*j<=g;j++){
                if(g%j==0){
                    if(p[j]||p[g/j]) return 0*puts("POSSIBLE");
                }
            }
        }
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 12160
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;
using namespace std;

signed main(){
    
    int n,m;
    cin >> n >> m;
    int a[31] = {0};
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int b;
            cin >> b;
            a[b]++;
        }
    }
    int ans = 0;
    for(int i = 1;i <= m;i++){
        if(a[i]==n)ans++;
    }
    cout << ans << endl;

    return 0;
}
//g++ -std=c++14 code1.cpp


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int r, c, k;

int mas[3010][3010] = {};
int memo[3010][3010][5];

int dp(int i, int j, int cnt){
	if(i == r-1 && j == c-1){
		int ans = 0;
		if(cnt < 3) ans = mas[i][j];
		return ans; 
	}

	if(memo[i][j][cnt] != -1) return memo[i][j][cnt];

	int ans = 0;
	if(i < r-1){
		chmax(ans, dp(i+1, j, 0));
		if(cnt < 3) chmax(ans, dp(i+1, j, 0)+mas[i][j]);
	}
	if(j < c-1){
		chmax(ans, dp(i, j+1, cnt));
		if(cnt < 3) chmax(ans, dp(i, j+1, cnt+1)+mas[i][j]);
	}
	return memo[i][j][cnt] = ans;
}

signed main(){
	cin >> r >> c >> k;

	for(int i = 0;i < k;i++){
		int rr, cc, v;
		cin >> rr >> cc >> v;
		mas[rr-1][cc-1] = v;
	}

	memset(memo, -1, sizeof(memo));

	cout << dp(0, 0, 0) << endl;

	return 0;
}


Measured memory_bytes: 428404
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>


#define ll long long

using namespace std;

string s,t;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
    cin >> s;
    cin >> t;
    
    ll int ct = 0;
    
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) ct++;
    }
    
    cout << ct << endl;
    
    
    
    
    
    
    
    
    
}


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

bool charcomp(char A[], char B[]) {
	
	bool hit = true;
	int i = 0;

	while (A[i] != 0) {
		if (A[i] != B[i]) {
			hit = false; 
			break;
		}
		i++;
	}

	return hit;

}

void charshift(char A[]) {

	char head = A[0];
	int i = 0;
	while( A[i] != 0) {
		A[i] = A[i+1];
		i++;
	}
	A[i-1] = head;


	return;
}

int main() {

	char t[101];
	char s[101];

	scanf("%s %s", &s, &t);

	int a;
	char re;
	for (int i = 0; i <= 100; i++) {

		//printf("%s %s\n", s, t);

		if (charcomp(s,t)) {
			printf("Yes\n");
			break;
		}else{
			if (i == 100) {
				printf("No\n");
				break;
			}

			re = s[0];
			charshift(s);

		}
	}


	return 0;
}

Measured memory_bytes: 128
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /root/Programming/Atcoder/C_management.cpp
 * Project: /root/Programming/Atcoder
 * Created Date: Sunday, April 19th 2020, 6:16:31 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sun Apr 19 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;
typedef set<int> seti;
typedef set<ll> setl;
typedef queue<int> qui;
typedef deque<int> dqui;

//Debug Setting up
#define watch(x) cout << (#x) << " is " << x << endl
#define watchara(wow)  \
    for (auto x : wow) \
    cout << x << " "

//defining something
#define SZ 10000

//main function start

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

    int n;
    scanf("%d", &n);
    n++;
    vi ans(n, 0);
    int num;
    for (int i = 2; i < n; i++)
    {
        scanf("%d", &num);
        ans[num]++;
    }
    for (int i = 1; i < n; i++)
    {
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 4072
*D, = open(0)
n = int(D[0])

edge = [[] for _ in range(n+1)]
v_val = [0 for _ in range(n+1)]

dist = {}

for i in range(1, n):
    a, b = map(int, D[i].split())
    edge[a].append(b)
    edge[b].append(a)
c = list(map(int, D[n].split()))
c = sorted(c, reverse=True)

from collections import deque
visited = [False for _ in range(len(edge))]
start = 1
que = deque()
que.append(start)
order = []
order.append(start)
visited[start] = True

while que:
    node = que.popleft()
    for it in edge[node]:
        if not visited[it]:
            order.append(it)
            visited[it] = True
            que.append(it)
# calculate cost
v_val = [0 for _ in range(len(c)+1)]
for i, it in enumerate(order):
    v_val[it] = c[i]

print(sum(c[1:]))
print(' '.join(map(str, v_val[1:])))

Measured memory_bytes: 7284
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let ans = max(a + b, max(a + a - 1, b + b - 1));
    return ans.to_string();
}


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

int main() {
  string b, ans;
  cin >> b;
  
  for (x : b){
    if (x == 'A'){
      ans += "T";
    }
    else if (x == 'T'){
      ans += "A";
    }
    else if (x == 'C'){
      ans += "G";
    }
    else if (x == 'G'){
      ans += "C";
    }

  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    dp = [[0] * (W+1) for _ in range(N+1)]

    for i in range(1, N+1):
        w, v = map(int, input().split())
        dp_pre = dp[i-1]
        for j in range(w):
            dp[i][j] = dp_pre[j]
        for j in range(w, W+1):
            dp[i][j] = max(dp_pre[j-w] + v, dp_pre[j])

    print(max(dp[N]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 118000
import sys
sys.setrecursionlimit(2*10**6)
class UF():
    def __init__(self, num):
        self.par = [-1]*num
        self.size = [1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
                self.size[rx] += self.size[ry] 
            elif self.par[rx] > self.par[ry]:
                self.par[rx] = ry
                self.size[ry] += self.size[rx]
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
                self.size[rx] += self.size[ry]
        return

N, M = map(int, input().split())
G = UF(N)
for _ in range(M):
    x, y, _ = map(int, input().split())
    G.union(x-1, y-1)
print(len(set([G.find(i) for i in range(N)])))

Measured memory_bytes: 90712
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " ";
    cout << x1 - y << " " << y1 + x << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a + b > c + d) {
        puts("Left");
    } else if (a + b == c + d) {
        puts("Balanced");
    } else {
        puts("Right");
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[21];
		int[] B = new int[21];
		int[] C = new int[21];
		int i = 0;
		int cs = 0;
		int csSum = 0;

		for( i = 0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		for( i = 0; i<N; i++) {
			B[i] = sc.nextInt();
		}

		for( i = 0; i<N-1; i++) {
			C[i] = sc.nextInt();
		}
		for(i = 1; i<=N; i++) {
			int j = A[i-1];
			if(A[i] == j+1) {
				cs = B[j-1] + C[j-1];
			}else {
				cs = B[j-1];
			}
			csSum += cs;
		}
		System.out.println(csSum);
		sc.close();
	}
}

Measured memory_bytes: 23636
n = int(input())
a = list(map(int,input().split()))

sum = 0
for i in range(n):
    sum += abs(a[i])

k = 0
for i in range(n):
    if a[i]<0:
        k += 1

if k%2 == 0:
    print(sum)
else:
    c = 10000000000
    for i in range(n):
        c = min(c,abs(a[i]))
    print(sum-2*c)


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

int main() {
    int a[4] = {0}, b;
    for(int i = 0; i < 6; i++){
        cin >> b;
        a[b]++;
    }
    sort(a, a+4);

    if(a[2] > 1) cout << "YES" << "\n";
    else cout << "NO" << "\n";

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
s = 0
for bar in a:
    if (s + bar) * 2 <= total:
        s += bar
    else:
        ans = min((s + bar) * 2 - total, total - s * 2)
        break

print(ans)


Measured memory_bytes: 26220
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
using namespace std;

int main(){
	int latte[2][1001]={},n=0;
	char str[100];
	for(int i=0;i<2;i++){
		while(fgets(str,100,stdin)){
			if(str[0]==10) break;
			latte[i][atoi(str)]++;
			n = max(n,atoi(str));
		}
	}
	for(int i=0;i<=n;i++){
		if(latte[0][i]>0 && latte[1][i]>0) printf("%d %d\n",i,latte[0][i]+latte[1][i]);
	}
    return 0;
}

Measured memory_bytes: 1128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, x, d; cin >> n >> x >> d;
  vector<long long> a{x};
  while (a.size() < n) a.emplace_back(a.back() + d);
  if (d == 0) {
    set<long long> st;
    REP(i, n + 1) st.emplace(1LL * x * i);
    cout << st.size() << '\n';
    return 0;
  }
  if (d < 0) {
    reverse(ALL(a));
    d *= -1;
  }
  vector<long long> smalls{0}, larges{0};
  REP(i, n) smalls.emplace_back(smalls.back() + a[i]);
  for (int i = n - 1; i >= 0; --i) larges.emplace_back(larges.back() + a[i]);
  map<int, set<pair<long long, int> > > mp;
  REP(i, n + 1) {
    long long small = smalls[i], large = larges[i];
    // cout << small << ' ' << large << '\n';
    int fst = ((small % d) + d) % d;
    auto it = mp[fst].lower_bound(make_pair(small, 0));
    if (it == mp[fst].end()) {
      mp[fst].emplace(small, 0);
      mp[fst].emplace(large, 1);
      continue;
    }
    bool ins_small = (*it).second == 0;
    while (it != mp[fst].end() && (*it).first <= large) it = mp[fst].erase(it);
    bool ins_large = it == mp[fst].end() || (*it).second == 0;
    if (ins_small) mp[fst].emplace(small, 0);
    if (ins_large) mp[fst].emplace(large, 1);
  }
  long long ans = 0;
  for (auto &pr : mp) {
    auto &st = pr.second;
    for (auto it = st.begin(); it != st.end(); ++it, ++it) {
      ans += ((*next(it)).first - (*it).first) / d + 1;
    }
  }
  cout << ans << '\n';
  return 0;


  // vector<vector<long long> > calc(n + 1);
  // REP(i, 1 << n) {
  //   long long sum = 0;
  //   REP(j, n) if (i >> j & 1) sum += a[j];
  //   calc[__builtin_popcount(i)].emplace_back(sum);
  // }
  // REP(i, n + 1) {
  //   cout << i << ": ";
  //   sort(ALL(calc[i]));
  //   calc[i].erase(unique(ALL(calc[i])), calc[i].end());
  //   for (long long e : calc[i]) cout << e << ' ';
  //   cout << '\n';
  // }
}


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

using namespace std;



int main(int argc, char* argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<string> w(n);
  for (auto& s : w) cin >> s;

  bool check = true;
  set<string> used{w[0]};

  for (int i = 1; check && i < n; ++i)
  {
    check = used.insert(w[i]).second && (w[i][0] == w[i-1].back());
  }

  cout << (check ? "Yes\n" : "No\n");

  return 0;
}


Measured memory_bytes: 256
import math
from math import degrees
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


a, b, x = LI()
x /= a
# 水が容器の半分より多い
if x >= a * b / 2:
    # 水のない部分の大きさ = a * (bの水がない部分 = c) / 2 より c部分が求まり tan(theta)が求められる
    tan = 2 * (a * b - x) / a ** 2
    theta = math.atan(tan)
    deg = math.degrees(theta)
# 水が容器の半分より少ない
else:
    tan = b ** 2 / (2 * x)
    theta = math.atan(tan)
    deg = math.degrees(theta)
print(deg)


Measured memory_bytes: 9404
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int a,b;
  cin >> a >> b;
  if(a < 10 && b < 10) printf("%d\n", a*b);
  else printf("-1\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int a = n % 10;
  string res;
  if(a == 3) res = "bon";
  else if(a == 0 || a == 1 || a == 6 || a == 8) res = "pon";
  else res = "hon";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

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

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}
//sort pair by first vals in descending
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.first > b.first); 
} 

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    int n;
    cin>>n;
    ll a[n];
    map<ll,ll> m;
    ll sum=0;
    f(i,n){
        cin>>a[i];
        sum+=a[i];
        m[a[i]]++;
    }
    int q;
    cin>>q;
    f(i,q){
        ll b,c;
        cin>>b>>c;
        ll s= m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        sum+=s;
        cout<<sum<<endl;

    }
    


    return 0;
}



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

#define endl "\n"
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define watch_vector(x) FOR(i,0,(v).size(),1) cout<<v[i]<<" ";
#define yo cout<<"yo"

typedef long long int LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int frogJump(VI &v,int K){
	int n=v.size();
	VI dp(n,INT_MAX);
	dp[n-1]=0;
	for(int i = n-2;i >= 0;i--){
		for(int k=1;k <= K;k++){
			if(i <= n-k-1) dp[i] = min(dp[i],abs(v[i] - v[i+k]) + dp[i+k]);
		}
		// if(i <= n-2) dp[i] = abs(v[i] - v[i+1]) + dp[i+1];
		// if(i <= n-3) dp[i] = min(dp[i],abs(v[i] - v[i+2]) + dp[i+2]);
	}
	return dp[0];
}
int main()
{
   ios_base:: sync_with_stdio(false); cin.tie(0);
   
   #ifndef ONLINE_JUDGE
		//for getting input from input.txt
		freopen("input.txt","r", stdin);
		//for writing output to output.txt
		freopen("output.txt","w", stdout);
	#endif

	int n,k;cin>>n>>k;
	VI v(n,0);
	FOR(i,0,n,1){
		cin>>v[i];
	}
	cout<<frogJump(v,k);
        
        
   return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  ll ans = 110000000000000000;
  for (int p = 0; p <= 1; p++) {
    ll sum = 0;
    ll tmp = 0;
    //cout << "p:" << p << endl;
    for (int i = 0; i < N; i++) {
      sum += a[i];
      // i%2 = pであるものが+でなければならない
      if (i % 2 == p) {
        if (sum <= 0) {
          tmp += -sum + 1;
          //cout << "cost :" << (-sum + 1) << endl;
          sum = 1;
        }
      } else {
        if (sum >= 0) {
          tmp += sum + 1;
          //cout << "cost :" << (sum + 1) << endl;
          sum = -1;
        }
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    int N,M; cin>>N>>M;
    int p; string S;
    
    vector<pair<int,int>> cnt(N+1);

    for (int i=0;i<M;i++) {
        cin >> p; cin >> S;
        
        if (S == "AC" && cnt[p].first == 0) {
            cnt[p].first += 1;
        }
        if (S == "WA" && cnt[p].first == 0) {
            cnt[p].second += 1;
        }
    }

    int AC=0,WA=0;
    for (int i=1;i<=N;i++) {
        AC += cnt[i].first;
        if (cnt[i].first != 0) WA += cnt[i].second;
    }

    cout << AC << " " << WA << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int W, H;
bool check(int y, int x) {
	if (y < 0 || y >= H)return false;
	if (x < 0 || x >= W)return false;
	return true;
}

const int BLACK = 1;
const int RED = -1;
vector<vb> Ans;
vvi Map;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,-1,1,0 };

void dfs(int x,int y){
	REP(i, 4) {
		int X = x + dx[i];
		int Y = y + dy[i];
		if (check(Y, X)) {
			if (Map[Y][X] == BLACK && (!Ans[Y][X])) {
				Ans[Y][X] = true;
				dfs(X,Y);
			}
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> W >> H;
	while (W != 0) {
		Ans = vector<vb>(H, vb(W, false));
		Map = vvi(H, vi(W, 0));
		int x = 0, y = 0;
		REP(i, H) {
			string S;
			cin >> S;
			REP(j, W) {
				if (S[j] == '.') {
					Map[i][j] = BLACK;
				}
				else if (S[j] == '#') {
					Map[i][j] = RED;
				}
				else {
					Map[i][j] = BLACK;
					x = j;
					y = i;
					Ans[i][j] = true;
				}
			}
		}
		dfs(x, y);
		int ans = 0;
		REP(i, H) {
			REP(j, W) {
				if (Ans[i][j])ans++;
			}
		}
		cout << ans << endl;
		cin >> W >> H;
	}
	return 0;
}



Measured memory_bytes: 3144
module practiceA
  sub Main(ByVal args() as String)
    	Dim arr as string
    	Dim kekka as string
    	arr=Console.ReadLine()
    
     	If arr.Substring(0, (arr.Length - 1) / 2) = arr.Substring((arr.Length + 3) / 2 - 1, arr.Length - (arr.Length + 3) / 2 + 1) Then
            kekka = "Yes"
        Else
            kekka = "No"
        End If
         
Console.WriteLine(kekka)

  end sub
end module

Measured memory_bytes: 21840
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int a , b , c;
        cin >> a >> b >> c ;
        int ans = 3;
        if( a == b && b == c  ){
            ans = 1;
        }else if( a == b || b == c || c == a){
            ans = 2;
        }
        cout << ans << endl;
        return 0;
    }

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int A, B;
    cin >> A >> B;
    cout << A * B - A - B + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define int ll

template < typename T > using indexed_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
 
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9+7, INF = INT_MAX, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int r;
   cin >> r;
   db ans = 2*PI*r;
   cout << setprecision(14) << fixed << ans << '\n';
   return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
const int maxN = 2e5+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	vector<lli> arr(n), pre(n);
	for(int i=0; i<n; i++) {
		cin >> arr[i];
		pre[i] = arr[i];
	}
	for(int i=n-2; i>=0; i--){
		pre[i] = (pre[i+1]+arr[i])%mod;
	}
	lli ans = 0;
	for(int i=0; i<n-1; i++){
		ans = (ans + (arr[i]*pre[i+1])%mod)%mod;
	}
	cout << ans ;
	
	//cout << "Hello World\n";
	return 0;
}

Measured memory_bytes: 6364
N, K = map(int, input().strip().split())
M = 10 ** 9 + 7

def calc_rev(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

def C(n, m):
	result = 1
	k = m
	while k > 0:
		result = (result * n) % M
		n -= 1
		k -= 1
	
	denom = 1
	while m > 1:
		denom = (denom * m) % M
		m -= 1
	return (result * calc_rev(denom, M)) % M

def factorial(n):
	result = 1
	while n > 1:
		result = (result * n) % M
		n -= 1
	return result

def factorial2(n, m):
	result = 1
	while n > m:
		result = (result * n) % M
		n -= 1
	return result

for i in range(1, K + 1):
	
	if i - 1 <= N - K:
		c1 = C(K - 1, i - 1)
		
		x1 = N - K - (i - 1)
		x2 = i + 1 - 1
		if x1 > x2:
			c2 = factorial2(x1 + x2, x1) * calc_rev(factorial(x2), M)
		else:
			c2 = factorial2(x1 + x2, x2) * calc_rev(factorial(x1), M)
		
#		print(c1, c2)
	
		print((c1 * c2) % M)
	else:
		print(0)





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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;
    int f= 1;
    REP(i,s.length()){
        if(i==a){
            if(s[i]!='-'){
                f= 0;
                break;
            }
        }else{
            if(0<=s[i]-'0' && s[i]-'0' <=9){

            }else{
                f=0;
                break;
            }        
        }
    }
    cout << ((f)?"Yes":"No") << endl;
}

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

N = int(input())
A = [0] + list(map(int,input().split()))
#A_ = A[:(N+1)]

for i in range(1,N+1):
    A[i] -= i

AA = sorted(A[1:N+1])
#print(AA)

if N % 2 == 0:
    b = AA[N//2 - 1]
else:
    b = AA[(N-1)//2]

ans = 0
for i in range(N):
    ans += abs(AA[i]-b)

print(ans)

Measured memory_bytes: 26104
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
ans = p_ans = sum(s)
if ans % 10 != 0: print(ans)
else:
    s = [s_i if s_i % 10 != 0 else 0 for s_i in s]
    for s_i in s:
        if s_i != 0:
            ans -= s_i
            break
    if ans == p_ans: print(0)
    else: print(ans)

Measured memory_bytes: 3060
import math
a, b, x = map(int, input().split())
if a * a * b < 2 * x:
    print(math.degrees(math.atan(2 * (a * a * b - x) / (a * a * a))))
else:
    print(math.degrees(math.atan(a * b * b / x / 2)))


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
 int a,b,c,n;

 cin >> a >> b >> c;
 n = 0;

 for(int i = a; i <= b ; i++){
  if(c % i == 0) n++;
 }

 cout << n << endl;

 return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int a,i,j,k,x,y;
	char ch[8][9],an[8][9];
	for (i=0;i<8;i++) gets(ch[i]);
	for (i=1;i<4;i++) {
		 for (y=0;y<8;y++) for(x=0;x<8;x++) an[x][7-y]=ch[y][x];
	   	 for (j=0;j<8;j++) for (k=0;k<8;k++) ch[j][k]=an[j][k];
		 cout << i*90 << endl; 
		 for (k=0;k<8;k++) cout << ch[k] << endl;
	}
 return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void print(T x){cout << x << endl;}
template<class T>void printvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];

    sort(ALL(p), greater<int>());sort(ALL(q), greater<int>());sort(ALL(r), greater<int>());
    // printvec(p);printvec(q);printvec(r);
    vector<int> eat(x+y);
    int pi=0, qi=0, ei=0;
    while(ei<x+y){
        if(qi==y || (pi<x && p[pi]>q[qi])){
            eat[ei] = p[pi];
            pi++;
        }else{
            eat[ei] = q[qi];
            qi++;
        }
        ei++;
    }
    // printvec(eat);
    int ri=0, tail=x+y-1;
    while(r[ri] > eat[tail]){
        eat[tail] = r[ri];
        tail--;
        ri++;
    }
    // printvec(eat);
    ll ans=0;
    rep(i, x+y) ans+=(ll)eat[i];
    
    print(ans);
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

const int MAX =2099999;
ll a[24][24];
ll n;
ll dp[MAX][22];



ll cnt(ll mask , ll pos ){
    if(pos  > n){
        if(mask == ((1ll<<n)-1))
            return 1;
        else
            return 0;
    }
    if(dp[mask][pos] != -1){
        return dp[mask][pos];
    }
    ll ans = 0;

    for(int i =0 ; i <n;i++){
        ll x= (1ll<<i);
        x = (x&mask);
        if( x == 0) {
            if(a[i+1][pos]){
                ll t= mask;
                t |= (1<<i);
                ans += cnt(t , pos+1);
                if(ans >= mod) ans -= mod;
            }
        }
    }
    return dp[mask][pos] = ans;

}
int main(){

   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   //ll n;
   cin>>n;
   rep(i ,1 , n+1){
    rep(j , 1 , n+1){
        cin>>a[i][j];
    }
   }
   memset(dp , -1, sizeof(dp));
  cout<<cnt( 0, 1);



}


Measured memory_bytes: 361216
from bisect import bisect_left as BL 
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

#border以上の幸福度を返す握手の組の数が、M以上であるか
def isok(border):
  res=0
  for i in range(N):
    res+=N-BL(A,border-A[i])
  return res>=M
    

ok=0
ng=A[-1]*2+1
mid=(ok+ng)//2

#幸福度h以上の握手がM組以上存在するような最大のhを探す
while abs(ok-ng)>1:
  mid=(ok+ng)//2
  if isok(mid):
    ok=mid
  else:
    ng=mid
  
B=reversed(A)
SB=[0]
for b in B:
  SB.append(b+SB[-1])
  
ans=0
shake_c=0
for i in range(N):
  goodshake=N-BL(A,ok-A[i])
  shake_c+=goodshake
  ans+=A[i]*goodshake
  ans+=SB[goodshake]  
ans-=(shake_c-M)*ok
print(ans)
  

Measured memory_bytes: 20724
s=input()[::-1]
for i in range(10**5):
  if s[:5]=="maerd":
    s=s[5:]
  elif s[:7]=="remaerd":
    s=s[7:]
  elif s[:5]=="esare":
    s=s[5:]
  elif s[:6]=="resare":
    s=s[6:]
  elif s=="":
    print("YES")
    break
  else:
    print("NO")
    break

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll t[100010],a[100010],T[100010],A[100010];
bool ch[100010];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		t[i]=x;
	}
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[i]=x;
	}
	ch[0]=true;ch[n-1]=true;
	for(ll i=1;i<n;i++){
		if(t[i-1]<t[i]){
			ch[i]=true;
			if(t[i]>a[i]){
				cout << 0;
				return 0;
			}
		}
	}
	for(ll i=n-2;i>=0;i--){
		if(a[i]>a[i+1]){
			ch[i]=true;
			if(a[i]>t[i]){
				cout << 0;
				return 0;
			}
		}
	}
	if(t[0]>a[0]){
		cout << 0;
		return 0;
	}
	if(a[n-1]>t[n-1]){
		cout << 0;
		return 0;
	}
	ll ans=1;
	for(ll i=0;i<n;i++){
		if(ch[i]){
	//		cout <<ans<<endl;
			continue;
		}
		ans*=min(t[i],a[i]);
		ans%=inf;
	//	cout << ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 3010

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
string s, t;
int n1, n2;
int dp[N][N];
int p[N][N];
int dpf(int i, int j)
{
	if(i == n1 || j == n2)
		return 0;
	if(dp[i][j] >= 0)
		return dp[i][j];
	if(s[i] == t[j])
	{
		dp[i][j] = 1 + dpf(i + 1, j + 1);
		p[i][j] = 2;
	}
	else
	{
		int k1, k2;
		dp[i][j] = max(k1 = dpf(i + 1, j), k2 = dpf(i, j + 1));
		if(dp[i][j] == k1)
			p[i][j] = 1;
		else
			p[i][j] = 3;
	}
	return dp[i][j];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> s >> t;
	n1 = s.size(), n2 = t.size();

	int i = 0, j;
	for(int i = n1 - 1; i >= 0; --i)
		for(int j = n2 - 1; j >= 0; --j)
		{
			if(s[i] == t[j])
				dp[i][j] = 1 + dp[i + 1][j + 1], p[i][j] = 2;
			else
			{
				dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
				if(dp[i][j] == dp[i+1][j])
					p[i][j] = 1;
				else
					p[i][j] = 3;
			}
		}
	string an;
	i = 0, j = 0;
	while(i < n1 && j < n2)
	{
		if(p[i][j] == 1)
			i++;
		else if(p[i][j] == 2)
			an += s[i], i++, j++;
		else
			j++;
	}
	cout << an << "\n";
	return 0;
}

Measured memory_bytes: 70912
import Control.Monad

isAcceptable :: Int -> Int -> Int -> Bool
isAcceptable a b c =
  (a == b + c) || (a + b == c) || (a + c == b)

main :: IO ()
main = do
  line <- getLine
  let [a, b, c] = read <$> words line :: [Int]
  putStrLn $ displayBool $ isAcceptable a b c
  where displayBool True = "Yes"
        displayBool False = "No"


Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL V, E, r; cin >> V >> E >> r;
		vector<pair<pair<UL, UL>, LL>> G(E);
		rep(i, E) {
			UL a, b; LL d; cin >> a >> b >> d;
			G[i] = { { a, b }, d };
		}
		const LL INF = 1000000000000;
		vector<LL> ans(V, INF);
		ans[r] = 0;
		rep(i, V - 1) {
			for (auto e : G) {
				UL u = e.first.first, v = e.first.second;
				LL d = e.second;
				if (ans[u] == INF) continue;
				ans[v] = min(ans[v], ans[u] + d);
			}
		}
		for (auto e : G) {
			UL u = e.first.first, v = e.first.second;
			LL d = e.second;
			if (ans[u] == INF) continue;
			if (ans[v] > ans[u] + d) { cout << "NEGATIVE CYCLE" << endl; return; }
		}
		rep(i, V) {
			if (ans[i] == INF) cout << "INF" << endl;
			else cout << ans[i] << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int k = int.Parse(s[2]);

            if ((b - a) <= (k * 2 - 1))
            {
                for (int i = a; i <= b; ++i)
                {
                    Console.WriteLine(i);
                }
            }
            else
            {
                for (int i = a; i < a + k; ++i)
                {
                    Console.WriteLine(i);
                }
                for (int i = b - k + 1; i <= b; ++i)
                {
                    Console.WriteLine(i);
                }
            }
        }
    }
}


Measured memory_bytes: 13140