akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n; cin>>n;
  VI c(n,0),s(n,0),f(n,0); rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
  cerr << "done" << endl;
  rep(i,n){
    int t = 0;
    rep(j,n-1){
      if(j<i) continue;
      if(t<s[j]) t=s[j];
      else if(t%f[j]==0);
      else t+=f[j]-t%f[j];
      t+=c[j];
    }
    cout << t << endl;
  }

  return 0;
}


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



int main(){
	int N;
	cin>>N;
	vector<int> X(N);
	
	for(int i=0;i<N;i++){
		cin>>X[i];
	}
	vector<int> sort_X=X;
	sort(sort_X.begin(),sort_X.end());
	int mid1 = sort_X[N/2-1];
	int mid2 = sort_X[N/2];
	
	for(int i=0;i<N;i++){
		if(X[i]<=mid1)cout<<mid2<<endl;
		else cout<<mid1<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 100
#define INF 100000

int main(){
  int n;
  cin >> n;
  int d[MAX][MAX];
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      d[i][j] = INF;
    }
  }
  for(int i = 0 ; i < n ; i++){
    int r,k,t;
    cin >> r >> k; r--;
    for(int j = 0 ; j < k ; j++){
      cin >> t; t--;
      d[r][t] = 1;
    }
  }
  for(int k = 0 ; k < n ; k++){
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int p,s,t,v;
  cin >> p;
  for(int i = 0 ; i < p ; i++){
    cin >> s >> t >> v; s--; t--;
    if(d[s][t]+1 <= v){
      cout << d[s][t]+1 << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#!/usr/bin/env python3

from sys import stdin, stdout

s = str(input())
length = len(s)
s1, s2, s3 = 0, 0, 0

def palindrome(start, end):

    for i, j in zip(range(start, end), range(end-1, 0, -1)):
        if (j == i):
            return 1
        if (s[i] != s[j]):
            print ("No")
            exit()

s1 = palindrome(0, length)
s2 = palindrome(0, int(((length-1)/2)))
s3 = palindrome(int(((length+3)/2))-1, length)

print ("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
cout<<C<<endl;
  }
  else if(A==C){
    cout<<B<<endl;
  }
  else if(B==C){
    cout<<A<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;
	cout << l - max(((a + c - 1) / c) , ((b + d - 1) / d)) << endl;
}


Measured memory_bytes: 3124
abc = sorted(list(map(int, input().split())))

if abc[2] - abc[1] == 1:
    target = abc[1]
else:
    target = abc[2]

res = 0
for i in range(3):
    res += -(-(target - abc[i]) // 2)
    if (target - abc[i]) % 2 == 1:
        res += 1

print(res)

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

int main() {
    long int n;
    cin>>n;
    long int a[n];
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long int count=0,ans=a[0];
    for(long int i=0;i<n-1;i++)
    {
        if(i&1)
        {
            ans=(ans+a[i+1]);
        }
        else
        {
            ans=(ans-a[i+1]);
        }
    }
    cout<<ans<<" ";
    for(long int i=0;i<n-1;i++)
    {
        ans=ans/2;
        a[i]=a[i]-ans;
        ans=2*a[i];
        cout<<ans<<" ";
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,m,a,b,c,d[100005] = {};
string s,t;

int main(){

    cin >> n ;
    rep(i,0,n)cin >> d[i];
 
    rsort(d,d+n,int);

    a = 0;b =0;
    rep(i,0,n){
        if(i % 2 == 0)a += d[i];
        else b += d[i];
    }
	
	P(a -b);
	return  0;
}

Measured memory_bytes: 256
n=[]
for i in range(int(input())):
	n.append(int(input()))
n_min=n[0]
n_max=n[1]-n_min
for i in range(1,len(n)):
	if n_max<n[i]-n_min:
		n_max=n[i]-n_min
	if n_min>n[i]:
		n_min=n[i]
print(n_max)


Measured memory_bytes: 13588
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : G - Mix Juice
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/6/2020
///****************************************************************************************************************************************///


vector<int>vec;
int k,sum=0,n,val;

int main()
{
cin>>n>>k;
for(int i=0;i<n;++i)
{
    cin>>val;
    vec.push_back(val);
}
sort(vec.begin(),vec.end());
for(int j=0 ;j<k;++j)
{
    sum+=vec[j];
}
cout <<sum <<endl;




return 0;
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

ll c0[30], c1[30], c2[30];
int main(void){
    ll n, c;
    cin >> n >> c;

    ll d[c][c];
    rep(i, 0, c){
        rep(j, 0, c){
            cin >> d[i][j];
        }
    }

    rep(i, 0, n){
        rep(j, 0, n){
            ll tmp;
            cin >> tmp;
            tmp--;
            if((i + j) % 3 == 0){
                c0[tmp]++;
            }
            if((i + j) % 3 == 1){
                c1[tmp]++;
            }
            if((i + j) % 3 == 2){
                c2[tmp]++;
            }
        }
    }

    ll mi = 10000000000000;
    ll cost;
    rep(i, 0, c){
        rep(j, 0, c){
            rep(k, 0, c){
                cost = 0;
                if(i == j || j == k || k == i){
                    continue;
                }
                rep(l, 0, c){
                    cost += c0[l] * d[l][i];
                    cost += c1[l] * d[l][j];
                    cost += c2[l] * d[l][k];
                }
                mi = min(cost, mi);
            }
        }
    }
    cout << mi << endl;
    return 0;
}


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

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

  int *p;
  p = (int *)calloc(sizeof(int), n);
  int i, ans = 0, min = 200000;
  for (i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    if (min >= p[i]) {
      ++ans;
      min = p[i];
    }
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 896
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		ArrayDeque<String> ans = new ArrayDeque<String>();
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("1")){
				ans.add("1");
			}
			if(s[i].equals("0")){
				ans.add("0");
			}
			if(s[i].equals("B")){
				if(ans.size()!=0){
					ans.removeLast();
				}		
			}
		}
		int roop = ans.size();
		for(int i = 0;i < roop;i++){
			System.out.print(ans.poll());
		}
		System.out.println("");
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(){
  char s[5];
  scanf("%s", s);
  int p = 700;

  for(int i = 0; i < 3; i++){
    if(s[i] == 'o'){
      p += 100;
      }
    }
  printf("%d", p);
  return 0;
}


Measured memory_bytes: 128
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun May  6 11:39:16 2018
//
package main

import (
	"fmt"
)

var s string

func main() {
	fmt.Scan(&s)

	found := false
	for i := range s {
		if s[i] == 'C' {
			found = true
		}
		if found && s[i] == 'F' {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i) for (int i = 1; i < 20; ++i)
using ll = long long;
using P = pair<int, int>;

int x;
bool ans = false;

int main() {
  cin >> x;
  rep (i) {
    if (100*i <= x && x <= 100*i + 5*i) ans = true;
  }
  if (2000 <= x) ans = true;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N,M,sum=0;
  cin >> N;
  for(ll i=2;i*i<=N;i++){
    M=N;
    while(M%i==0){
      M /= i;
    }
    if(M%i==1){
      sum++;
    }
    if(N%i==1){
      sum++;
    }
    if(N==i*i+1){
      sum--;
    }
  }
  sum += 2;
  if(N==2){sum=1;}
  cout << sum << endl;
}

  

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split(' ').map(String::toInt)

    if(a + b > c + d) {
        print("Left")
    } else if(a + b < c + d) {
        print("Right")
    } else {
        print("Balanced")
    }

}

Measured memory_bytes: 38204
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
/////////////////////

int const N = 1e5 + 41;
int n;
int t[N], x[N], y[N];

void bad(){
	printf("No\n");
	exit(0);
}

void solve(){
	fi(1, n+1){
		int d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
		int dt = t[i] - t[i-1];
		if(d > dt) bad();
		if( (dt - d) % 2 == 1) bad();
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d",&n);
	fi(1, n+1) scanf("%d %d %d",&t[i],&x[i],&y[i]);

	solve();

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 1408
N = str(input())

l = len(N)

if l <= 1:
	print(int(N))
elif l == 2:
	print(9)
elif l == 3:
	print(int(N[0]) * 100 + int(N[1]) * 10 + int(N[2]) - 90)
elif l == 4:
	print(999 - 90)
elif l == 5:
	print(int(N[0]) * 10000 + int(N[1]) * 1000 + int(N[2]) * 100 + int(N[3]) * 10 + int(N[4]) - 90 - 9000)
else:
	print(90909)

Measured memory_bytes: 38256
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val taxi = array(2)
  val train = array(0) * array(1)

  if(train >= taxi) {
    println(taxi)
  } else {
    println(train)
  }
}

Measured memory_bytes: 25540
program abc112c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,cx,cy,ph,xx,yy,hh
    integer(int32), allocatable:: x(:),y(:),h(:)
    logical:: ok

    read*, n
    allocate(x(n), y(n), h(n))
    xx=0; yy=0; hh=0
    do i=1,n
        read*, x(i),y(i),h(i)
        if (h(i) /= 0) then
            xx=x(i); yy=y(i); hh=h(i)
        end if
    end do
    ph = -1
    do cy=0,100
        do cx = 0,100
            ph = hh + abs(xx-cx) + abs(yy-cy)
            ok = .true.
            do i=1,n
                if (h(i) /= max(ph - abs(x(i)-cx) - abs(y(i)-cy), 0)) ok=.false.
            end do
            
            if (ok) then
                print'(*(i0,1x))', cx,cy,ph
                stop
            end if
        end do
    end do
end program abc112c

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    while(sc.hasNext()){
	    	long a=sc.nextLong();
	    	long b=sc.nextLong();
	        System.out.println(gcd(a,b)+" "+a/gcd(a,b)*b);
	    }
	}
	public static long gcd(long a,long b){
		if(b==0)return a;
		else return gcd(b,a%b);
	} 
}
//by TTTMongolia 11/05/2012

Measured memory_bytes: 12000
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200002
int n,s;
struct node
{
	int a,b;
}x[MAXN];
bool cmp(node x,node y)
{
	return x.b<y.b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i].a,&x[i].b);
	sort(x+1,x+n+1,cmp);
	for(int i=1;i<=n;i++)
		if(s+x[i].a<=x[i].b)
		{
			s+=x[i].a;
		}
		else
		{
			printf("No");
			return 0;
		}
	printf("Yes");
}

Measured memory_bytes: 1664
N = int(input())
b = list(map(int,input().split()))

valid = True
for i,a in enumerate(b,1):
    if i < a :
        valid = False
if valid :
    out = []
    while len(b) > 0:
        m = 0
        for i,a in enumerate(b,1):
            if i == a :
                m = i
        out.append(m)
        b.pop(m-1)
else:
    out = [-1]

for s in out[::-1]:
    print(s)

Measured memory_bytes: 3064
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from fractions import gcd

    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    cnt = [0] * n

    for i, elem in enumerate(a):
        x = elem
        c = 0
        while x % 2 == 0:
            x //= 2
            c += 1
        cnt[i] = c

    ans = 0

    if len(set(cnt)) == 1:
        lcm = a[0]
        for elem in a[1:]:
            lcm = (lcm * elem) // gcd(lcm, elem)
        ans = (m + (lcm // 2)) // lcm

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 85228
#include<stdio.h>

int main(void)
{
   int n, m, a[50], b[50], x[50]={0}, i;

   scanf("%d%d",&n,&m);
   for(i=0;i<m;i++)
      scanf("%d%d",&a[i],&b[i]);

   for(i=0;i<m;i++){
      x[a[i]-1]++;
      x[b[i]-1]++;
   }

   for(i=0;i<n;i++)
      printf("%d\n",x[i]);
   return 0;
}

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

int main() {
  int N , A , x;
  cin >> N >> A;
  x = N % 500;//まずNを５００円玉で割ったあまり
  if (x <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] t = new long[n];
		for(i=0;i<n;i++) {
			t[i] = parseLong(sc.next());
		}
		sc.close();
		long a = t[0];
		for (i = 1; i < n; i++) {
			a = lcm(a,t[i]);
		}
		out.println(a);
	}
	public static long lcm(long a, long b) {
		return (a / gcm(a, b)) * b;
	}
	public static long gcm(long a, long b) {
		long tmp;
		while((tmp = a % b) != 0) {
			a = b;
			b = tmp;
		}
		return b;
	}
}


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

int N;

void Equivalance(char *a,char mx,int i){
	if(i == N){
      a[i] = '\0';
		cout<<a<<endl;
		return;
	}

	for(char ch = 'a';ch<=mx;ch++){
		a[i] = ch;
		if(ch == mx){
			Equivalance(a,mx+1,i+1);
		}
		else{
			Equivalance(a,mx,i+1);
		}
	}
}

int main(){
	cin>>N;
	char a[100];
	Equivalance(a,'a',0);

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    int n;
    cin >> n;

    int count = 0;

    rep(i,n){
        int tmp;
        cin >> tmp;

        if(tmp != i + 1) count++;
        
    }

    if(count == 0 || count == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for k in range(N):
    t = 0
    T = set([x for x in S[:k]])
    U = set([x for x in S[k:]])
    for x in T:
        if x in U:
            t += 1
    ans = max(ans,t)

print(ans)

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

using namespace std;

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int g = gcd(a, b);
  int ans = g;
  for (int i = 0; i < k - 1; ++i) {
    ans--;
    while (g % ans != 0) ans--;
  }
  cout << ans << endl;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B;
  cin >> A >> B;

  cout << std::max({A + B, A - B, A * B}) << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int n, m, arr[N], prime[N], ans = 1, inArray[N];
void sieve(){
    for(int i = 2; i < N; i++){
        int cnt = 0;
        if(!prime[i])
        for(int j = i; j < N; j += i){
            prime[j] = 1;
            cnt += inArray[j];
        }
        if(cnt >= 2){ans = i;}
    }
}
int main(){
    cin >> n ;
    int GCD = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        inArray[arr[i]]++;
        GCD = __gcd(arr[i], GCD);
    }
    sieve();
    if(ans == 1){
        cout << "pairwise coprime" << endl;
    }else if(GCD == 1)
        cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    
    return 0;
}

Measured memory_bytes: 15244
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    x,n=L()
    if n!=0:p=L()
    z=[]
    for i in range(0,105):
        flag=False
        for j in range(n):
            if i==p[j]:
                flag=True
                break
        if(flag): continue
        z.append(i)
    
    mini=1e+5
    ans=1e+5
    for i in range(len(z)):
        absxz=abs(x-z[i])
        if absxz<mini:
            mini=absxz
            ans=z[i]
    print(ans)
            
    
if __name__ == '__main__':
    main()


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

signed main(){
	vi fact{1};
	FOR(i,1,114514)
		fact.PB(fact.back()*i%mod);
	vi factInv;
	for(auto v:fact)
		factInv.PB(modInv(v));
	const auto comb=[&](int a,int b){
		return fact[a]*factInv[b]%mod*factInv[a-b]%mod;
	};
	int n=read(),k=read();
	int ans=0;
	if(k==1)
		ans=1;
	else{
		add(ans,comb(n-2+k-1,k-1));
		if(k>=3)
		sub(ans,comb(n-2+k-1,k-3));
	}
	if(n-k>0)
	mult(ans,modPow(2,n-k-1));
	cout<<ans<<endl;
}


Measured memory_bytes: 2676
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	if A.count(0) > 0:
		print(sum([abs(a) for a in A]))
		return 0
	minus = 0
	for i in range(len(A)):
		if A[i] < 0:
			minus += 1
	if minus % 2 == 0:
		print(sum([abs(a) for a in A]))
		return 0
	A.sort(key=lambda a: abs(a))
	print(sum([abs(a) for a in A[1:]]) - abs(A[0]))

main()


Measured memory_bytes: 20280
import java.util.Scanner;

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

        for(int i=1; i<line+1; i++) {
            sum += i;
        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
long long sol(long long h){
    if(h==1) return 1;
    if(h%2) return 1+2*sol(h/2);
    long long t=1, s=0;
    while(h%2==0){
            s+=t;
            t*=2;
            h/=2;
    }
    return s+t*sol(h);
}
int main(){
    long long h;
    cin>>h;
    cout<<sol(h);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> h(n+1);
	for(int i = 1; i <= n; i++) cin >> h[i];
	long long dp[n+1];
	dp[1] = 0, dp[2] = abs(h[2]-h[1]);
	for(int i = 3; i <= n; i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout << dp[n] << '\n';
	return 0;
}


Measured memory_bytes: 4580
#include<iostream>
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define mod 10000000007
#define pb push_back

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;
typedef long long ll;


int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
int gcd(int a,int b,int &x,int &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}
	int x1,y1;
	int ans = gcd(b, a%b, x1, y1);
	x = y1;
	y = x1 - y1 * (a/b);
	return ans;

}
int main(){
 /*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    string a;
    string b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<a.length();i++)
    	if(a[i]!=b[i])
    		ans++;
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
  int X,p=1;
  cin >> X;
  for(int i=1; i<X; i++){
    for(int j=2; j<X; j++){
      if(X>=pow(i,j) && pow(i,j)>p){
        p=pow(i,j);
      }
    }
  }cout << p << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k, x; cin >> k >> x;
	if (k == 1) { cout << x << endl; return 0; }
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  ll n,k; cin>>n>>k;
  vector<ll> d(100005,0);
  rep(i,n){
    int a,b; cin>>a>>b;
    d[a]+=(ll)b;
  }
  ll B=0;
  rep(i,100005){
    B+=d[i];
    if(B>=k){
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;cin>>s;
	int ans=0;
	for(char c:s){
		(ans+=c-'0')%=9;
	}
	cout<<(!ans?"Yes":"No")<<endl;
}

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

int main(){
    int H,W;
    while(cin >> H >> W,H!=0 && W!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;        
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(){
	
	int i,n,input,max=-1000001,min=1000001;
	long sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&input);
		sum+=input;
		if(input>max){
			max=input;
		}
		if(input<min){
			min=input;
		}
		
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
bool prime[1000000];
int a[1000000];
void mainmain(){
    int n;
    rep(i,1000000){
        prime[i]=true;
    }
    prime[0]=prime[1]=false;
    for(int i=2;i*i<=1000000;i++){
        if(prime[i]){
            for(int j=i*i;j<1000000;j+=i){
                prime[j]=false;
            }
        }
    }
    rep(i,1000000){
        if(!i) continue;
        a[i]=a[i-1];
        if(prime[i]) a[i]++;
    }
    while(cin>>n){
        if(!n) return;
        ll ans=0;
        rep(i,n){
            int x,y;
            cin>>x>>y;
            int l=max(1,x-y);
            int r=min(1000000-1,x+y);
            int t=a[r]-a[l-1]-1;
            // cout<<x<<" "<<y<<" "<<t<<" "<<l<<" "<<r<<endl;
            ans+=t;
        }
        cout<<ans<<endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>k(n);
  vector<int>cnt(m,0);
  for(int i=0;i<n;i++){
    cin >> k[i];
    vector<int>ai(k[i]);
    for(int j=0;j<k[i];j++){
      cin >> ai[j];
      cnt[ai[j]-1]++;
    }
  }
  
  int ans=0;
  for(int i=0;i<m;i++){
    if(cnt[i]==n){
      ans++;
    }
  }
  cout << ans;
}
  


Measured memory_bytes: 256
N,K = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
expect = 0
for i in range(N-K+1):
    if i == 0:
        expect = sum([(p[i]+1)/2 for i in range(K)])
        ans = expect
    else:
        expect = expect - ((p[i-1] + 1) / 2) + ((p[i+K-1] + 1) / 2)
        ans = max(ans, expect)
print(ans)

Measured memory_bytes: 24548
toInt :: String -> Int
toInt = read :: String -> Int

getAnsList :: (Int, Int, Int, Int) -> [(Int, Int, Int)]
getAnsList (r, g, b, n) = [(rc, gc, bc) | rc <- [0..rm], gc <- [0..gm], let bc = div (n-rc*r-gc*g) b, bc >= 0, rc*r+gc*g+bc*b == n]
  where
    rm = div n r
    gm = div n g

main = do
  [r, g, b, n] <- map toInt . words <$> getLine
  print $ length $ getAnsList (r, g, b, n)


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll gcd(ll a, ll b){
    if(a==0){
        return b;
    }
    return gcd(b%a, a);
}

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  


int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    map<ii, ll> m1;
    ll c1=0;
    ll c2=0;
    ll ct=0;
    for (int i = 0; i < n; ++i)
    {
        ll a,b;
        cin>>a>>b;
        if((a!=0) && (b!=0)){
            ll g = gcd(a, b);
            a=(a/g);
            b=(b/g);
            if((a<0) && (b<0)){
                m1[{abs(a), abs(b)}]++;
            }
            else if((a>0) && (b>0)){
                m1[{a, b}]++;
            }
            else if((a<0) && (b>0)){
                m1[{a, b}]++;
            }
            else{
                m1[{-a, -b}]++;
            }            
        }
        else if((a==0) && (b==0)){
            ct++;
        }
        else if(a==0){
            c1++;
        }
        else if(b==0){
            c2++;
        }
    }

    ll ans=1;

    while(m1.begin()!=m1.end()){
        ii p1 = m1.begin()->F;
        ll p11 = m1.begin()->S;
        ii p2;
        p2.S = abs(p1.F);
        p2.F = abs(p1.S);
        if(p1.F>0){
            p2.F=-p2.F;
        }
        ll x1 = p11;
        ll x2=0;
        m1.erase(m1.find(p1));
        if(m1.find(p2)!=m1.end()){
            x2=m1[p2];
            m1.erase(m1.find(p2));
        }
        ll v = (power(2, x1, mod)+power(2, x2, mod)-1+mod)%mod;
        ans = (ans*v)%mod;
    }
    ll v1 = (power(2, c1, mod)+power(2, c2, mod)-1+mod)%mod;
    ans=(ans*v1)%mod;

    ans = (ans+ct-1+mod)%mod;
    cout<<ans;

    return 0;
}


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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long long toLL(string s) {long long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const long INF = 100000001;
const LL MOD=100007;

long sumh[1503],sumw[1503];
int main(){
	int N,M;
	CLR(sumh);CLR(sumw);
	while(cin>>N>>M&&N!=0&&M!=0){
		long res=0;
		//CLR(sumh);CLR(sumw);
		REP(i,N){
			int h;
			cin>>h;
			sumh[i+1]=h+sumh[i];
		}
		REP(i,M){
			int w;
			cin>>w;
			sumw[i+1]=w+sumw[i];
		}
		vector<long>wbs;
		REP(i,M)FOR(j,i+1,M+1)wbs.PB(sumw[j]-sumw[i]);
		wbs.PB(INF);
		SORT(wbs);
		REP(i,N)FOR(j,i+1,N+1){
			res+=upper_bound(ALL(wbs),sumh[j]-sumh[i])-lower_bound(ALL(wbs),sumh[j]-sumh[i]);
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 26956
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
from collections import defaultdict
d = defaultdict(int)
s="Yes"
for i in range(n):
 x=input()
 if i>0 and y[-1]!=x[0]:
   s="No"
 d[x]+=1
 if d[x]>1:
   s="No"
 y=x
print(s)

Measured memory_bytes: 38704
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,c[50],sum;
	cin>>a>>b;
	for(int i=0;i<a;i++) {
		cin>>c[i];
	}
	sort(c,c+a,greater<int>());
	sum=0;
	for(int i=0;i<b;i++) {
		sum+=c[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())

xl = x2-x1
yl = y2-y1

x3 = x2 - yl
y3 = y2 + xl
x4 = x1 - yl
y4 = y1 + xl

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int sum, value;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		while(read()){
			slove();
		}
	}
	static boolean read(){
		sum = 0;
		value = 0;
		sum = sc.nextInt();
		
		if(sum == 0){
			
			return false;
		}
		
		for(int i = 0; i < 9; i++){
			value += sc.nextInt();
		}
		
		return true;
	}
	static void slove(){
		System.out.println(sum-value);
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

template<typename M, typename N>
istream& operator>>(istream&is, pair<M,N> & p){is >> p.first >> p.second; return is;}
template<typename M>
istream& operator>>(istream&is, vector<M> & v){for(auto &it:v) is >> it; return is; }
template<typename M>
istream& operator>>(istream&is, vector<vector<M>> & v){for(auto &it:v) is >> it; return is; }
template<typename M, typename N>
ostream& operator<<(ostream&os, const pair<M,N> &p){os << p.fi << ' ' << p.se << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<M> &v){for(auto it: v)os << it << ' ';cout << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<vector<M>> &v){for(auto it: v)os << it;return os;}

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=2010;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int s;
    cin >> s;
    if(s<3){
        cout << 0 << el;
    }
    else{
        vi dp(s+1, 0);
        dp[0]=1;
        for(int i=3; i<=s; i++){
            for(int j=i-3; j>=0; j--){
                (dp[i]+=dp[j])%=mod;
            }
        }
        cout << dp[s] << el;
    }
    
    return 0;
}







Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c;
    cin >> a >> b >> c;
    if(a - b < c){
        cout << c - (a - b) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,c; cin >> a >> b >> c;
    cout << (b-a==c-b?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    string max1="ABC";
    string max2="ARC",max;
    getline(cin,max);
    if(max==max1){
        cout<<max2;
    }
    else cout << max1;
    cout<< endl;
}

Measured memory_bytes: 3656