akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
void ng() {
    output("UNRESTORABLE");
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s, t;
    cin >> s >> t;
    if(t.size() > s.size()) ng();
    vector<string> ret;
    for(int i = (int)(s.size() - t.size()); i >= 0; i--){
        string u = s.substr(i, t.size());
//        cout << i << ":" << u << endl;
        bool ok = true;
        rep(j, u.size()){
            if(u[j] != '?' && t[j] != u[j]) ok = false;
        }
        if(ok){
            string v = s;
            rep(j, u.size()){
                v[j + i] = t[j];
            }
            rep(j, s.size()){
                if(v[j] == '?') v[j] = 'a';
            }
            ret.pb(v);
        }
        
    }
//    rep(i, ret.size()) output(ret[i]);
    if(ret.size() == 0) ng();
    sort(all(ret));
    output(ret.front());
    
    return 0;
}


Measured memory_bytes: 256
import math
a,b,x = map(float, input().split())

def ok(mid,a,b,x_s):
    x = a * math.sin(mid*math.pi/180)/math.sin(math.pi/2 - (mid * math.pi/180))
    s = 0
    if b - x > 0:
        s = (b - x + b)/2 * a
    else:
        x = b * math.sin(math.pi/2 - (mid * math.pi/180))/math.sin(mid*math.pi/180)
        s = 0.5 * x * b
    if s < x_s:
        return -1
    else:
        return 1

def bin_search(a,b,x):
    l = 0.0
    r = 90.0
    while abs(l - r) > 1e-10:
        mid = l + (r - l)/2
        res = ok(mid,a,b,x)
        if res < 0:
            r = mid
        else:
            l = mid
    return r


#def toFixed(numObj, digits=0):
#    return f"{numObj:.{digits}f}"


print(bin_search(a,b,x/a))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll a[501][501];
int main(){

int h,w,h1,w1;
cin>>h>>w>>h1>>w1;
if(((h1==h)&&(w1==w))||((h1==1)&&(w1==1))||((h%h1==0)&&(w%w1==0)))
    cout<<"No"<<endl;
else{

    cout<<"Yes"<<endl;

int inx=1;
int indy=1;
ll x=502;
ll y=(ll)h1*w1*502-501;
y=-y;
int i,j;
for(i=1;i<=h;i++)
for(j=1;j<=w;j++){

    if((i%h1==0)&&(j%w1==0))
        a[i][j]=y;
    else
        a[i][j]=x;



}


    for(i=1;i<=h;i++){

        for(j=1;j<=w;j++)
            cout<<a[i][j]<<" ";

        cout<<endl;
    }


}


return 0;
}


Measured memory_bytes: 3328
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
    int x=sc.nextInt();
//    int a=sc.nextInt();
//    int b=sc.nextInt();
    System.out.println(x/3);
  }
}

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

using namespace std;

#define M 4005
#define N 200005
#define delta 2001
#define MOD 1000000007
#define ll int
//#define int long long

int n;
int a[N], b[N];
ll ans;
int f[M][M], mns[M][M];

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
	{
		a[i] = read(), b[i] = read();
		f[-a[i] + delta][-b[i] + delta]++;
	}

 for (int i = 1; i <= delta*2; i++)
		for (int j= 1; j <= delta*2; j++)
			(f[i][j] += (f[i-1][j] + f[i][j-1]) % MOD) %= MOD;
	mns[1][1] = 1;
	for (int i = 1; i <= 4004; i++)
		for (int j = 1; j <= 4004; j++)
			(mns[i][j] += (mns[i-1][j] + mns[i][j-1]) % MOD) %= MOD;

	for (int i = 1; i <= n; i++)
	{
		(ans += f[a[i]+delta][b[i]+delta]) %= MOD;
		((ans -= mns[a[i]*2+1][b[i]*2+1]) += MOD) %= MOD;
	}

	cout << 1ll * ans * 500000004 % MOD;

	return 0;
}

Measured memory_bytes: 130380
#include <iostream>
#define R(i,n) for(i=0;i<n;i++)
using namespace std;
int main()
{
long long int a[100][100],b[100][100],c[100][100]={0};
int n,m,l,i,j,k;
cin>>n>>m>>l;
R(i,n)R(j,m)cin>>a[i][j];
R(i,m)R(j,l)cin>>b[i][j];
R(i,n)R(j,l)R(k,m)c[i][j]+=a[i][k]*b[k][j];
R(i,n){R(j,l){
if (j)cout<<' ';
cout<<c[i][j]; 
}
cout<<endl;
}
}

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

long N, answer = 1;

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

  cin >> N;

  long divide_num = 1;
  for (int i = 0; i < 9; i++) {
    divide_num *= 10;
  }
  divide_num += 7;

  for (int i = 1; i <= N; i++) {
    answer *= i;
    answer %= divide_num;
  }
  cout << answer << endl;
}

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  if a>9:
    return -1
  if b>9:
    return -1
  return a*b

# main()
print(main())


Measured memory_bytes: 6604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

ll gcd(ll a, ll b){
        if(b == 0) return a;
        return gcd(b, a % b);
}
// 最小公倍数
ll lcm(ll a, ll b){
        return a / gcd(a, b) * b;
}

int main(int argc, char const *argv[]) {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll cd = lcm(c, d);
  cout << b-(b/c)-(b/d)+b/cd-((a-1)-((a-1)/c)-((a-1)/d)+(a-1)/cd) << endl;

  return 0;
}

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

using namespace std;

class Node {
public:
	int key;
	Node* prev;
	Node* next;
	Node(int _key, Node* _prev, Node* _next) {
		key = _key;
		prev = _prev;
		next = _next;
	}
};

class List {
public:
	Node* head;
	Node* last;
	List() {
		head = NULL;
		last = NULL;
	}
	void insert(int key) {
		auto node = head;
		head = new Node(key, NULL, node);
		if (node)
			node->prev = head;
		else
			last = head;
	}
	void deleteNode(Node* node) {
		if (! node)
			return;
		
		if (node == head)
			head = node->next;
		else
			node->prev->next = node->next;
		if (node == last)
			last = node->prev;
		else
			node->next->prev = node->prev;
		delete node;
	}
	Node* find(int key) {
		Node* current = head;
		while (current) {
			if (current->key == key) {
				break;
			} else {
				current = current->next;
			}
		}
		return current;
	}
	void deleteFirst() {
		deleteNode(head);
	}
	void deleteLast() {
		deleteNode(last);
	}
};

int main() {
	int n;
	cin >> n;
	
	auto list = List();
	string name;
	int key;
	for (int i=0; i<n; i++) {
		cin >> name;
		if (name == "insert") {
			cin >> key;
			list.insert(key);
		} else if (name == "delete") {
			cin >> key;
			list.deleteNode(list.find(key));
		} else if (name == "deleteFirst") {
			list.deleteFirst();
		} else if (name == "deleteLast") {
			list.deleteLast();
		}
	}
	
	auto current = list.head;
	while (current) {
		if (current != list.head)
			cout << ' ';
		cout << current->key;
		current = current->next;
	}
	cout << endl;
}

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

int main()
{
    char a,b,c;
    scanf("%c %c",&a,&b);
    if(a=='H')
    {
        if(b=='H')
            c='H';
        if(b=='D')
            c='D';
    }
    if(a=='D')
    {
        if(b=='H')
            c='D';
        if(b=='D')
            c='H';
    }
    printf("%c\n",c);
}

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

char s[111];
int md = 1e9;

int main(){
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 'a'; i <= 'z'; i++){
		int cmd = 0, l = -1;
		for(int j = 0; j < n; j++){
			if(s[j] == i){
				cmd = max(cmd, j - l - 1);
				l = j;
			}
		}
		cmd = max(cmd, n - l - 1);
		md = min(md, cmd);
	}
	printf("%d\n", md);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    map<char, int> m; m['a'], m['b'], m['c'];
    int n = s.length();
    REP(i,n) ++ m[s[i]];
    bool ans = ((max({m['a'], m['b'], m['c']}) - min({m['a'], m['b'], m['c']}))<2);
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
vector<pair<pll,ll>>v;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
	string s;
	cin>>s;
	if(s.size()>=3){cout<<s[0]<<s[1]<<s[2]<<endl;}
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

Measured memory_bytes: 5992
import math

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

k = readInt()
a,b = readInts()

for n in range(a,b+1):
	if n%k==0:
		print("OK")
		exit()

print("NG")

Measured memory_bytes: 9180
package main

import "fmt"

func main() {
	var n, ma, mb int
	fmt.Scanf("%d %d %d", &n, &ma, &mb)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)
	var abMax, cMax int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d %d", &a[i], &b[i], &c[i])

		if a[i] > abMax {
			abMax = a[i]
		}

		if b[i] > abMax {
			abMax = b[i]
		}

		if c[i] > cMax {
			cMax = c[i]
		}
	}

	mixMax := n*abMax + 1
	priceMax := n*cMax + 1

	// Initialize.
	dp := make([][][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([][]int, mixMax)
		for j := 0; j < mixMax; j++ {
			dp[i][j] = make([]int, mixMax)
			for k := 0; k < mixMax; k++ {
				dp[i][j][k] = priceMax
			}
		}
	}

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

	for i := 0; i < n; i++ {
		for ca := 0; ca < mixMax; ca++ {
			for cb := 0; cb < mixMax; cb++ {
				if dp[i][ca][cb] == priceMax {
					continue
				}

				dp[i+1][ca][cb] = selectMin(dp[i+1][ca][cb], dp[i][ca][cb])
				dp[i+1][ca+a[i]][cb+b[i]] = selectMin(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])
			}
		}
	}

	ans := priceMax
	for ca := 1; ca < mixMax; ca++ {
		for cb := 1; cb < mixMax; cb++ {
			if ca*mb == cb*ma {
				ans = selectMin(ans, dp[n][ca][cb])
			}
		}
	}

	if ans == priceMax {
		ans = -1
	}

	fmt.Println(ans)
}

func selectMin(x, y int) int {
	if x < y {
		return x
	}

	return y
}

Measured memory_bytes: 59520
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int H = ni();
        int W = ni();
        int N = ni();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = ni();
        }
        int[][] ans = new int[H][W];
        
        int h = 0;
        int w = 0;
        int c = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < a[i]; j++) {
                ans[h][w] = c+1;
                if(h%2==0 && w < W-1) w++;
                else if(h%2==0 && w == W-1) h++;
                else if(h%2==1 && w>0) w--;
                else if(h%2==1 && w==0) h++;
            }
            c++;
        }


        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                out.print(ans[i][j]);
                if(j<W-1) out.print(" ");
                else out.println();
            }
        }
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 35392
def dropcell(h, w, rm):
  for i in range(w):
    y=0
    for j in range(h):
      if rm[h-j-1][i]!=0:
        rm[h-y-1][i]=rm[h-j-1][i]
        y+=1
    for j in range(h-y):
      rm[h-y-j-1][i]=0

def removecell(h, w, k, rm, a):
  p=0
  for y in range(h):
    c,t=1,0
    for i in range(w+1):
      x=rm[y][i]
      if x>0 and x==t:
        c+=1
      else:
        if c>=k:
          for j in range(c):
            rm[y][i-1-j]=0
          p+=(t*c)
        t=x
        c=1
  return p*(2**a)

def game(h,w,k,M,y,x):
  f,score,a=1,0,0
  rm=[[j for j in i]for i in M[:y+1]]
  rm[y][x]=0
  while f:
    dropcell(len(rm),w,rm)
    f=removecell(len(rm),w,k,rm,a)
    score+=f
    a+=1
  return score

H,W,K=map(int,input().split())
M=[list(map(int,list(input())))+[0] for i in range(H)]
ans=0
for j in range(W):
  t=0
  for i in range(1, H):
    if M[i][j]!=t:
      ans=max(ans,game(H,W,K,M,i,j))
      t=M[i][j]
print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
const float PI = 3.14;


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

	int time = 0;
	for (int i = 0; i < m;  i++) {
		int in; cin >> in;
		time += in;
	}

	if (n - time < 0) {
		cout << -1 << endl;
	}
	else {
		cout << n - time << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3604
n , m = gets.split.map(&:to_i)
# check = Hash.new(0)
ans = {}
ans2 = 0
pena = Hash.new(0)
pena2 = 0
m.times do |i|
  s , t = gets.chomp.split
  # p s, t
  if !ans[s].nil?
    next
  elsif t == "WA"
    # check[s] += 1
    pena[s] += 1
  elsif t == "AC"
    ans[s] = 1
    ans2 += 1
    pena2 += pena[s]
  end
end
puts "#{ans2} #{pena2}"

Measured memory_bytes: 15228
import java.util.Scanner;

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

        while (b != 0) {
            int c = a % b;
            a = b;
            b = c;
        }
        System.out.println(a);
    }
}



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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll x,y;
    cin>>x>>y;
    ll ans = 0;
    ll c[3];
    c[0] = 300000;
    c[1] = 200000;
    c[2] = 100000;
    for(int i=0;i<3;i++){
        if(x==i+1) ans += c[i];
        if(y==i+1) ans += c[i];
    }
    if(x==1 && y==1){
        cout << ans + 400000 << endl;
        return 0;
    }
    cout << ans << endl;

}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int n;
    cin >> n;
    ll x[n], y[n], h[n];
    rep(n){
        cin >> x[i] >> y[i] >> h[i];
    }

    Pll C = Pii(0, 0);
    while(C.first <= 100){
        C.second = 0;
        while(C.second<= 100){
            for(int i=0;i<n;i++){
                bool ok = true;
                ll H = h[i] + abs(C.first-x[i]) + abs(C.second-y[i]);
                if(H <= 0) continue;
                for(int j=0;j<n;j++){
                    if(i == j) continue;
                    if(max(0LL, H - abs(C.first-x[j]) - abs(C.second-y[j])) != h[j]){
                        ok = false;
                        break;
                    }
                }
                if(ok){
                    cout << C.first << " " << C.second << " " << H << endl;
                    return 0;
                }
            }
            C.second++;
        }
        C.first++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint k; cin >> k;
  lint r = k % 50;
  cout << 50 << '\n';
  REP(i, 50) cout << 51 * (i < r) + 49 - r + k / 50 << (i != 49 ? ' ' : '\n');
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        //カード枚数
        int number=0;
        //入力を格納する配列
        int[] S = new int[13];
        int[] H = new int[13];
        int[] C = new int[13];
        int[] D = new int[13];
        
        Scanner scan = new Scanner(System.in);
        //枚数を格納
        number = scan.nextInt();
        
        for(int i=0;i<number;i++){
            String design = scan.next();
            int cnum = scan.nextInt();
            
            if(design.equals("S")){
                check(S,cnum);
            }
            if(design.equals("H")){
                check(H,cnum);
            }
            if(design.equals("C")){
                check(C,cnum);
            }
            if(design.equals("D")){
                check(D,cnum);
            }
            
        }
        
        for(int i=0;i<13;i++){
            if(S[i]==0){
                System.out.println("S "+(i+1));
            }
        }
        for(int i=0;i<13;i++){
            if(H[i]==0){
                System.out.println("H "+(i+1));
            }
        }
        for(int i=0;i<13;i++){
            if(C[i]==0){
                System.out.println("C "+(i+1));
            }
        }
        for(int i=0;i<13;i++){
            if(D[i]==0){
                System.out.println("D "+(i+1));
            }
        }
        
        
    }

    private static void check(int[] design, int cnum) {
        design[cnum-1]=1;
    }
}

Measured memory_bytes: 18044
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[1001], order[8], ch[1001];
  int i, j, n, a, b;
 
  scanf("%s\n%d", s, &n);
 
  for(i=0;i<n;i++){
    scanf("%s %d %d", order, &a, &b);
     
    if(!strcmp(order, "reverse")){
      for(j=a;j<=b;j++)
        ch[b-j] = s[j];
      for(j=a;j<=b;j++)
        s[j] = ch[j-a];
    }
 
    if(!strcmp(order, "replace")){
      scanf("%s", ch);
      for(j=0;ch[j]!='\0';j++)
        s[a+j] = ch[j];
    }
 
    if(!strcmp(order, "print")){
      for(j=a;j<=b;j++)
        printf("%c", s[j]);
      printf("\n");
    }
  }
 
  return 0;
}



Measured memory_bytes: 2104
from math import factorial


def nCk(n, k):
    return factorial(n) // factorial(k) // factorial(n-k)


N, P = map(int, input().split())
A = [int(x) & 1 for x in input().split()]
even, odd = A.count(0), A.count(1)
print((1 << even) * sum(nCk(odd, i) for i in range(P == 1, odd + 1, 2)))


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

int main()
{
    int a[3];
    int b[60006]={0};
    int n,f;
    scanf("%d",&n);
    for(int i=1;i<100;i++)
    {
        for(int j=1;j<100;j++)
        {
            for(int z=1;z<100;z++)
            {
                a[0]=i;
                a[1]=j;
                a[2]=z;
                f=a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[0]*a[1]+a[1]*a[2]+a[0]*a[2];
                b[f]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",b[i]);
    }
    return 0;
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1e9+7;
using namespace std;
using ll = long long;

int main() {
	int ans = 0;
	string s, t;
	cin >> s >> t;
	rep(i,s.size()) if(s[i] != t[i])ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3916
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  cout << n * n * n << endl;
}



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

using namespace std;

int N;
char s[1010];

int main()
{
	scanf("%d",&N);
	scanf("%s",s+1);
	int ans=0,tmp=0;
	for (int i=1;i<=N;i++)
	{
		if (s[i]=='D') tmp--;
		else tmp++;
		ans=max(ans,tmp);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

f :: [Int] -> (Int, Int)
f xs = g (0, 0) xs
g (up, dn) (s:xs@(t:_))
  | s > t = g (up, max dn (s-t)) xs
  | s < t = g (max up (t-s), dn) xs
  | otherwise = g (up, dn) xs
g r _ = r

main = readLn >>= flip replicateM_ (getLine >> (f . map read . words <$> getLine) >>= \(u, d) -> putStrLn $ show u ++ " " ++ show d)


Measured memory_bytes: 4120
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const int N=1e5+5;
ll arr[N];
ll brr[N];
void solve(){
	ll n;
	cin>>n;
	ll x;
	cin>>x;
	for ( ll i=0;i<n;i++){
		cin>>arr[i];
		brr[i]=arr[i];
	}
	ll ans=1e18;
	for ( ll i=0;i<n;i++){
		ll tot=0;
		for ( ll j=0;j<n;j++){
			brr[(i+j)%n]=min( brr[(i+j)%n],arr[j]);
			tot+=brr[(i+j)%n];
		}
		tot+=i*x;
		ans=min( ans,tot);
	}
	cout<<ans<<'\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 3648
using System;

namespace ALDS1_4_B_binary_
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] S = getsplit();
            int[] s2 = new int[S.Length];
            for (int i = 0; i < S.Length; i++)
            {
                s2[i] = getint(S[i]);
            }
            
            Console.ReadLine();
            string[] T = getsplit();
            int count=0;

            foreach (var t in T)
                if (BinarySearch(s2, getint(t)))
                    count++;

            Console.WriteLine(count);
        }

        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint(string a)
        {

            if (a == null || a.Length == 0)
            {
                int x = int.Parse(Console.ReadLine());
                return x;
            }
            else
            {
                int x = int.Parse(a);
                return x;
            }
        }

        static bool BinarySearch(int[] a,int key)
         {
            int left = 0;
            int right = a.Length;

            while (left<right)
            {
                int mid = (left + right) / 2;
                if (a[mid] == key)
                {
                    return true;
                }
                else if (key < a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }
            return false;
         }
    }
}

Measured memory_bytes: 18944
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    string S, T;

    cin >> S >> T;

    T = T + T;

    bool able_rot = false;
    for(int i = 0; i < S.length(); i++){
        if(S == T.substr(i, S.length())){
            able_rot = true;
        }
    }

    if(able_rot){
        cout << "Yes" << endl;
    }else{
        cout << "No" << 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)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    vector<int> water;
    vector<int> sugar;

    for(int i = 0; i <= 30; ++i){
        for(int j = 0; j <= 30; ++j){
            if(i == 0 and j == 0) continue;
            int tmp = 100*a*i+100*b*j;
            if(tmp > f) break;
            water.push_back(tmp);
        }
    }
    for(int i = 0; i <= 1000; ++i){
        for(int j = 0; j <= 1000; ++j){
            int tmp = c*i+d*j;
            if(tmp > f) break;
            sugar.push_back(tmp);
        }
    }

    double mx = -1;
    int sw = 0, sg = 0;
    rep(i, water.size()){
        rep(j, sugar.size()){
            if(water[i]+sugar[j] > f) continue;
            if(sugar[j]*100 > water[i]*e) continue;
            double con = (double)sugar[j]/(water[i]+sugar[j]);
            if(con > mx){
                mx = con;
                sw = water[i]+sugar[j];
                sg = sugar[j];
            }
        }
    }
    cout << sw << sp << sg << endl;

    return 0;
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = LLONG_MAX;

map<lint, lint> cost;
lint T, N, A, B, C, D;

lint fun(lint i) {
	if (cost.find(i) != cost.end()) return cost[i];
	cost[i] = 1e18;
	chmin(cost[i], fun(i / 2) + abs(i - ((i / 2) * 2)) * D + A);
	chmin(cost[i], fun((i + 1) / 2) + abs(i - ((i + 1) / 2) * 2) * D + A);
	chmin(cost[i], fun(i / 3) + abs(i - ((i / 3) * 3)) * D + B);
	chmin(cost[i], fun((i + 2) / 3) + abs(i - ((i + 2) / 3) * 3) * D + B);
	chmin(cost[i], fun(i / 5) + abs(i - ((i / 5) * 5)) * D + C);
	chmin(cost[i], fun((i + 4) / 5) + abs(i - ((i + 4) / 5) * 5) * D + C);
	if (cost[i] / D >= i) cost[i] = i * D;
	return cost[i];
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> T;
	vector<lint> ans;
	REP(i, T) {
		cin >> N >> A >> B >> C >> D;
		cost.clear();
		cost[0] = 0;
		cost[1] = D;
		ans.push_back(fun(N));
	}
	REP(i, T) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 4448
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

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

int const A_MAX = 100000;
ll const X_MAX = 1000000000000000000;

int A, B, Q;
ll ss[A_MAX + 3], ts[A_MAX + 3], xs[A_MAX + 1];

int bin_s(ll x, ll list[A_MAX + 1], int n) {
  int idx = -1;

  int l = 0;
  int r = n - 1;
  while (r - l > 4) {
    int i = (l + r) / 2;
    if (x < list[i]) {
      r = i;
    } else {
      l = i;
    }
  }
  FOR(i, l, r + 1) {
    if (list[i] > x) return  i;
  }
  return idx;
}

int main() {
  scanf("%d %d %d", &A, &B, &Q);
  ss[0] = X_MAX * -1;
  ts[0] = X_MAX * -1;
  ss[A + 1] = X_MAX;
  ts[B + 1] = X_MAX;
  REP(i, A) scanf("%lld", &ss[i + 1]);
  REP(i, B) scanf("%lld", &ts[i + 1]);
  REP(i, Q) scanf("%lld", &xs[i]);


  REP(i, Q) {
    ll x = xs[i];
    int si = bin_s(x, ss, A + 2);
    int ti = bin_s(x, ts, B + 2);
    ll dist = X_MAX * 2;
    REP(n, 2) {
      REP(m, 2) {
        ll s_p = ss[si - n];
        ll t_p = ts[ti - m];
        ll s_d = abs(s_p - x) + abs(t_p - s_p);
        ll t_d = abs(t_p - x) + abs(s_p - t_p);

        dist = min(dist, min(s_d, t_d));
      }
    }
    printf("%lld\n", dist);
  }
}


Measured memory_bytes: 3584
N = int(input())

A = [int(_) for _ in input().split()]


def f(sign):
    ans = 0
    s = 0
    for i in range(N):
        a = A[i]
        s += a
        if s == 0:
            ans += 1
            s = sign
        else:
            a_sign = s // abs(s)
            if a_sign != sign:
                ans += abs(s) + 1
                s = sign
        sign *= -1
    return ans


print(min(f(1), f(-1)))


Measured memory_bytes: 14332
N,M = map(int, input().split())
A_B=[]
for i in range(N):
  A_B.append(tuple(map(int, input().split())))
A_B.sort()
cnt = 0
m = 0
price = 0
while m < M:
  if A_B[cnt][1] > M-m:
    price += A_B[cnt][0]*(M-m)
    m = M
  else:
    price += A_B[cnt][0]*A_B[cnt][1]
    m += A_B[cnt][1]
  cnt += 1
print(price)

Measured memory_bytes: 17004
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

int main()
{
  const double eps = 1e-10;

  Vector a, b, c, d;
  
  while ( cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y )
    {
      if ( fabs( Vector::dot( b - a, d - c ) ) < eps )
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  
  return 0;
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
int mod=1e9+7;
int C[5005][5005];
void build(){
    for(int i = 0;i<5005;i++){
        C[i][0]=C[i][i]=1;
        for(int j = 1;j<i;j++){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }
}
void solve(){
    build();
    int s;
    scanf("%d",&s);
    LL ans=0;
    for(int i = 1;i*3<=s;i++){
        ans+=C[i-1+s-i*3][i-1];
        ans%=mod;
    }
    printf("%lld\n",ans);
}
int main(){
    int t=1;
    int T=1;
    while(t--){
        solve();
    }
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/

Measured memory_bytes: 70708
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int A,B;
int main(){
	cin>>A>>B;
	cout<<(A-1)*(B-1)<<endl;
	return(0);
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [S() for _ in range(n)]
    c = collections.defaultdict(int)
    for s in a:
        if s[0] in 'MARCH':
            c[s[0]] += 1

    r = 0
    t = 'MARCH'
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                r += c[t[i]] * c[t[j]] * c[t[k]]

    return r


print(main())




Measured memory_bytes: 14512
#include<stdio.h>

int main(){
    int a,b,c,k;
    scanf("%d %d %d %d",&a, &b, &c, &k);
    if(k<=a){
        printf("%d",k);
    }else if(k<=a+b){
        printf("%d",a);
    }else if(k>a+b){
        printf("%d",a-(k-(a+b)));
    }
}

Measured memory_bytes: 1728
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.next());
    double[] p = new double[n];
    double[][] dp = new double[n + 1][n + 1];
    for (int i = 0; i < n; i++) {
      p[i] = Double.parseDouble(scanner.next());
    }
    dp[0][0] = 1;
    for (int i = 1; i < n; i++) {
      dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]);
      dp[0][i] = 0;
    }

    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < i + 1; j++) {
        dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
      }
    }
    System.out.println(Arrays.stream(Arrays.copyOfRange(dp[n], (n + 1) / 2, n + 1)).sum());
  }
}


Measured memory_bytes: 133916
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;
    cin>>s;
    int n = s.size();
    int cnt[26]={};
    cnt[s[0]-'a']++;
    for(int i=1;i<n;i++){
       cnt[s[i]-'a']++;
       if(cnt[s[i]-'a']==2){
           printf("%d %d\n", i, i+1);
           return 0;
       } 
       cnt[s[i-1]-'a']--;
    }
    rep(i,26){
        cnt[i]=0;
    }
    cnt[s[0]-'a']++;cnt[s[1]-'a']++;
    for(int i=2;i<n;i++){
        cnt[s[i]-'a']++;
        if(cnt[s[i-2]-'a']>=2||cnt[s[i-1]-'a']>=2){
           printf("%d %d\n", i-1, i+1);
           return 0;
        }
        cnt[s[i-2]-'a']--;
    }
    printf("-1 -1\n");
    return 0;
}


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

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C)
{
    vector<pair<ll, ll>> BC;
    for (ll i = 0; i < M; ++i) {
        BC.emplace_back(B[i], C[i]);
    }
    sort(begin(BC), end(BC), [](auto&& a, auto&& b) { return a.second > b.second; });

    sort(begin(A), end(A));
    ll w_idx = 0;
    for (auto&& bc : BC) {
        for (ll i = 0; i < bc.first && w_idx < (ll)A.size() && A[w_idx] < bc.second; ++i) {
            A[w_idx] = bc.second;
            w_idx++;
        }
    }

    ll ans = accumulate(begin(A), end(A), 0LL);
    cout << ans << "\n";
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    cin.tie(nullptr);
    cout.tie(nullptr);
	ios_base::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 4852
#include <stdio.h>

int main( void ) {
	int n, debt = 100000;

	scanf( "%d", &n );
	while ( n-- ) {
		debt *= 1.05;

		if ( debt % 1000 )
			debt = ( debt / 1000 + 1 ) * 1000;
	}

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

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

struct LCA{
private:
    int V;
    int logV;
    int root;
    vvi G; // 隣接ノード
    vvi  parent; // parent[k][v] : vが親を2^k会辿って到着する頂点

    void dfs(int v, int p, int d){ // v:ノード、 p:vの親、 d:vの深さ。
        parent[0][v] = p;
        depth[v] = d;
        FORE (next, G[v]) {
        if (next != p) dfs(next, v, d+1); 
        } 
    }

public:
    vi depth;

    LCA(const vvii &g) {
        G = vvi(g.size());
        REP (i, g.size()) FORE (x, g[i]) {
            G[i].PB(x.first);
        }
        V = g.size();
        logV = log2(V)+1;
        parent = vvi(logV, vi(V));
        depth = vi(V);
        root=0;
        dfs(root, -1, 0);

        REP (k, logV-1) REP (v, G.size()) {
            if (parent[k][v] < 0) parent[k+1][v] = -1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }

    int lca(int u,int v) {
        if (depth[u] > depth[v]) swap(u, v);
        REP (k, logV) if ((depth[v]-depth[u])>>k & 1) {
            v = parent[k][v];
        }
        if (u==v) return u;
        REPR (k, logV) {
            if (parent[k][u] != parent[k][v]) {
                u = parent[k][u];
                v = parent[k][v];
            }
        }
        return parent[0][u];
    }

    vvi getG(){
        return G;
    }
};

const int MAX = 1e5+10;

int N, Q;
vi VUA[MAX];
viii info[MAX];
vii edge;
vvii G;
map<int, ii> used;
bool visit[MAX];

ll dfs(int n, ll sum) {
    visit[n] = true;
    FORE (in, info[n]) {
        ll q = get<0>(in), x = get<1>(in), y = get<2>(in);
        ll res = sum - used[x].second + used[x].first * y;
        VUA[q].PB(res);
    }
    FORE (x, G[n]) if (!visit[x.first]) {
        int next = x.first, idx = x.second;
        int c = edge[idx].first, d = edge[idx].second;
        used[c].first++;
        used[c].second += d;
        dfs(next, sum+d);
        used[c].first--;
        used[c].second -= d;
    }
}

int main() {
    cin >> N >> Q;
    G = vvii(N);
    REP (i, N-1) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--;
        G[a].PB(MP(b, i));
        G[b].PB(MP(a, i));
        edge.PB(MP(c, d));
    }
    LCA tree(G);
    REP (q, Q) {
        int x, y, u, v, a;
        cin >> x >> y >> u >> v; u--; v--;
        a = tree.lca(u, v);
        iii t = MT(q, x, y);
        info[a].PB(t);
        info[u].PB(t);
        info[v].PB(t);
    }

    dfs(0, 0);
    REP (q, Q) {
        sort(ALL(VUA[q]));
        cout << VUA[q][1] + VUA[q][2] - 2 * VUA[q][0] << "\n";
    }
}

Measured memory_bytes: 63216
def c(ints):
        
    sig = -1
    sig_ = +1
    total = 0
    total_ = 0
    mov = 0
    mov_ = 0
    
    for i_ in ints:
        tmp = total + i_
        tmp_ = total_ + i_
        if tmp == 0:
            mov +=1
            tmp = -sig
        elif sig * tmp > 0:
            mov += abs(tmp) + 1
            tmp = -sig
            
        if tmp_ == 0:
            mov_ +=1
            tmp_ = -sig_
        elif sig_ * tmp_ > 0:
            mov_ += abs(tmp_) + 1
            tmp_ = -sig_
            
        sig *= -1
        total = tmp
        sig_ *= -1
        total_ = tmp_

    return min(mov, mov_)

_ = input()
inp = input()
inp = inp.split(' ')
inp = [int(i_) for i_ in inp]
print(c(inp))

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N - 1) {
        if (a[i] == a[i + 1]) {
            ans++;
            a[i + 1] = 101 + i;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256