akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF (1LL<<59)

ll d[20][100][100];
vector<int> q[20];
vector<int> r[20];

ll f(ll dist,int c){
	if(dist==INF)return INF;
	ll ret=0;
	for(int i=1;;i++){
		if(q[c][i]<dist){
			ret+=(q[c][i]-q[c][i-1])*r[c][i-1];
		}
		else return ret+(dist-q[c][i-1])*r[c][i-1];
	}
}


int main(){
	int n,m,c,s,g;
	while(cin>>n>>m>>c>>s>>g&&(n||m||c||s||g)){
		rep(i,20)rep(j,100)rep(k,100)d[i][j][k]=INF;
		rep(i,m){
			int x,y,di,cam;
			cin>>x>>y>>di>>cam;
			x--,y--,cam--;
			d[cam][x][y]=min<ll>(di,d[cam][x][y]);
			d[cam][y][x]=min<ll>(di,d[cam][y][x]);
		}
		
		vector<int> b(c);
		rep(i,c)cin>>b[i];
		rep(i,c){
			q[i].resize(b[i]+1);
			q[i][0]=0, q[i][b[i]]=200000000;
			r[i].resize(b[i]);
			rep(j,b[i]-1)cin>>q[i][j+1];
			rep(j,b[i])cin>>r[i][j];
		}
		
		
		rep(p,20){
			rep(wk,n){
				rep(wi,n){
					rep(wj,n){
						d[p][wi][wj] = min(d[p][wi][wk]+d[p][wk][wj],d[p][wi][wj]);
					}
				}
			}
		}
		
		rep(p,20){
			rep(wi,n){
				rep(wj,n){
					d[p][wi][wj] = f(d[p][wi][wj],p);
				}
			}
		}
		
		ll pass[100][100];
		rep(i,100){
			rep(j,100){
				pass[i][j]=INF;
			}
		}
		
		rep(wi,n){
			rep(wj,n){
				rep(p,20){
					pass[wi][wj] = min(pass[wi][wj],d[p][wi][wj]);
				}
			}
		}
		
		rep(wk,n){
			rep(wi,n){
				rep(wj,n){
					pass[wi][wj] = min(pass[wi][wk]+pass[wk][wj],pass[wi][wj]);
				}
			}
		}
		
		if(pass[s-1][g-1]==INF)cout<<-1<<endl;
		else cout<<pass[s-1][g-1]<<endl;
	}
}

Measured memory_bytes: 4716
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
mod = 10**9 + 7

def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


for key, val in cnt.items():
    if val == 2:
        doubled_num = key
        break

left = None
for i, a in enumerate(A):
    if a == doubled_num:
        if left == None:
            left = i
        else:
            right = i

rest = n - right
base_numerator = n+1
base_denominator = 1
base = (base_numerator * mod_inv(base_denominator, mod)) % mod
duplicate_numerator = left + rest + 1
duplicate_denominator = 0
duplicate = 1
for i in range(n+1):
    #print("base", base_numerator, base_denominator)
    #print("dup", duplicate_numerator, duplicate_denominator)
    #print(base, duplicate)
    print((base - duplicate) % mod)

    base_numerator -= 1
    base_denominator += 1
    base *= base_numerator * mod_inv(base_denominator, mod)
    base %= mod
    duplicate_numerator -= 1
    duplicate_denominator += 1
    duplicate *= duplicate_numerator * mod_inv(duplicate_denominator, mod)
    duplicate %= mod

Measured memory_bytes: 100944
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int A, B, C, D, E, F;
int dp[31][3007];
int cand[31];

int input(){
  cin >> A >> B >> C >> D >> E >> F;
  for( int i = 0; i < 31; i++ ){
	for( int j = 0; j < 3007; j++ ){
	  dp[i][j] = 0;
	}
  }
  return 0;
}

int calc(){
  int li = (F-E)/100, lj = 0, ni = 0, nj = 0;
  dp[0][0] = 1;
  for( int i = 0; i <= li; i++ ){
	if( dp[i][0] <= 0 ){ continue; }
	ni = i + A;
	if( ni <= li ){	dp[ni][0] = 1; }
	ni = i + B;
	if( ni <= li ){	dp[ni][0] = 1; }
  }
  for( int i = 0; i <= li; i++ ){
	lj = F - 100 * i;
	for( int j = 0; j <= lj; j++ ){
	  if( dp[i][j] <= 0 ){ continue; }
	  nj = j + C;
	  if( 100 * i + nj <= F && nj <= i * E ){ dp[i][nj] = 1; }
	  nj = j + D;
	  if( 100 * i + nj <= F && nj <= i * E ){ dp[i][nj] = 1; }
	}
  }
  return 0;
}

int main(){
  input();
  calc();

  for( int i = 0; i < 31; i++ ){
	int m = 0;
	for( int j = 0; i+j <= F && j <= E * i; j++ ){
	  if( dp[i][j] ){ m = j; }
	}
	if( m ){
	  cand[i] = m;
	  //cout << 100 * i << "," << cand[i] << endl;
	}else{
	  cand[i] = 0;
	}
  }

  int ci = A;
  for( int i = A+1; i < 31; i++ ){
	if( cand[i] == 0 ){ continue; }
	/*
	cout << ci << "," << i << ":" << (i+cand[i]) * 100 * cand[ci] << "," << (ci+cand[ci]) * 100 * cand[i] << endl;
	cout << cand[ci] << "," << cand[i] << endl << endl;
	*/
	if( (i+cand[i]) * 100 * cand[ci] < (ci+cand[ci]) * 100 * cand[i] ){ ci = i; }
  }
  cout << 100 * ci + cand[ci] << " " << cand[ci] << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] lArray = new int [n];
		int sum = 0, lon = 0;
		for(int i = 0; i < n; i++) {
			lArray[i] = sc.nextInt();
			sum = sum + lArray[i];
			if(lon <= lArray[i]) lon = lArray[i];
		}
		if(lon < (sum - lon)) System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	stack<int>S1;
	stack<pair<int, int>>S2;
	char ch;
	int sum = 0;
	for (int i = 0;cin>>ch;i++) {
		if (ch == '\\')S1.push(i);
		else if (ch == '/' && S1.size() != 0) {
			int j = S1.top(); S1.pop();
			sum += i - j;//总面积
			int a = i - j;//某部分面积 ，并且高为1，形状为矩形或可转化为就想到等边梯形
			while (S2.size() > 0 && S2.top().first > j) {// S2 中存的面积是 某个大水洼 面积的一部分
				a += S2.top().second; S2.pop();
			}
			pair<int, int>temp;
			temp = { j,a };
			S2.push(temp);
		}
		else if (ch == '0')break;
	}
	cout << sum <<endl<< S2.size();
	vector<int>VR(S2.size());
	int cnt = S2.size();
	for (int i = 0; i < cnt; i++) {
		VR[i] = S2.top().second;
		S2.pop();
	}
	reverse(VR.begin(), VR.end());
	for (int i = 0; i < VR.size(); i++)
		cout << " " << VR[i];
	cout << endl;
	return  0;
}
//    \\\\/_/\\///


Measured memory_bytes: 3256
#include <iostream>
#include <stdio.h>
#include <ctype.h>
using namespace std;
 
int main() {
char cs[1201];
scanf("%[^\n]",cs);
for(int i=0;cs[i]!='\0';i++){
	char c=cs[i],c2;
	if(tolower(c)!=c){
		c2=tolower(c);
	}else if(toupper(c)!=c){
		c2=toupper(c);
	}else{
		c2=c;
	}
	printf("%c",c2);
}
printf("\n");
return 0;
}


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

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  if(s1.length()>s2.length())cout << "GREATER"<<endl;
  else if(s1.length()<s2.length())cout << "LESS"<<endl;
  else {
    if(s1>s2)cout << "GREATER"<<endl;
    else if(s1<s2)cout << "LESS"<<endl;
    else cout << "EQUAL"<<endl;
  }
}

Measured memory_bytes: 256
n=int(input())
INF=10**7
w=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
dp=[INF]*100001
dp[0]=0
for i in range(100001):
  for j in w:
    if i+j>100000:continue
    dp[i+j]=min(dp[i]+1,dp[i+j])
print(dp[n])

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

int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(s=="Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
n , m = map(int, input().split())
s = input()
t = input()

def gcd(num1,num2):
    r=1
    while r!=0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    return num1*num2//gcd(num1,num2)

g1 = lcm(n,m)
g2 = lcm(g1//n,g1//m)

for i in range(g1//g2):
    if s[g2*n*i//g1]!=t[g2*m*i//g1]:
        print('-1')
        exit()
print(g1)


Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N, A[2];
bool ok[1000][1000];

int main() {
    while (cin >> N >> A[0] >> A[1]) {
        for (int i = 0; i < 1000; ++i) for (int j = 0; j < 1000; ++j) ok[i][j] = true;
        int num[2] = {0};
        for (int iter = 0; iter < 2; ++iter) {
            num[iter] = 0;
            while (A[iter] % 2 == 0) {
                ++num[iter];
                A[iter] /= 2;
            }
        }

        for (int iter = 0; iter < 2; ++iter) {
            int p = num[iter];
            
            //COUT(p);
            
            if (p & 1) {
                int two = 1<<(p/2);
                for (int x = 0; x < N*2; ++x) {
                    for (int y = 0; y < N*2; ++y) {
                        if (y % (two*2) >= two) ok[x][y] = false;
                    }
                }
            }
            else {
                int two = 1<<(p/2);
                for (int x = 0; x < N*2; ++x) {
                    for (int y = 0; y < N*2; ++y) {
                        int px = (x % (two*2) >= two ? 1 : 0);
                        int py = (y % (two*2) >= two ? 1 : 0);
                        if (px != py) ok[x][y] = false;
                    }
                }
            }
        }
        
        int con = 0;
        for (int x = 0; x < N*2; ++x) {
            for (int y = 0; y < N*2; ++y) {
                if (con == N*N) break;
                if (ok[x][y]) {
                    cout << x << " " << y << endl;
                    ++con;
                }
            }
        }
    }
}


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


public class Main
{	
	static int W;
	static int N;
	static int w[];
	static int p[];
	static int test[][];

	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		
		int Case  = 1;
		do{
			if((W = Integer.parseInt(s)) == 0) break;
			N = Integer.parseInt(br.readLine());

			w = new int[N];
			p = new int[N];
			test = new int[N+1][W+1];
			for (int i = 0; i < N; i++) {
				String d = br.readLine();
				p[i] = Integer.parseInt(d.split(",")[0]);
				w[i] = Integer.parseInt(d.split(",")[1]);
			}
			int weight = theaf();
			System.out.println("Case " + Case + ":");
			System.out.println(test[N][weight]);
			System.out.println(weight);
			Case++;
		} while((s=br.readLine())!=null);
		
	}
	
	private static int theaf()
	{ 
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= W; j++) {
				if(j<w[i]){
					test[i+1][j] = test[i][j];
				} else {
					test[i+1][j] = Math.max(test[i][j], test[i][j-w[i]]+p[i]);
				}	
			}
		}
		//search for minimum weight
		int min = W;
		for (int i = W; i > 0; i--) {
			if(test[N][i-1] == test[N][i])
				min = i-1;
			else
				break;
		}
		return min;
	}
}

Measured memory_bytes: 27452
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;

class Pair {
	int x;
       	int y;
	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int dx[] = {2, 0, -2, 0};
		int dy[] = {0, 2, 0, -2};
		while (true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w == 0 && h == 0) break;
			int[][] maze = new int[2 * h - 1][2 * w - 1];
			for (int i = 0; i < 2 * h - 1; ++i)
				for (int j = 0; j < 2 * w - 1; ++j)
					maze[i][j] = -1;
			for (int i = 0; i < 2 * h - 1; ++i)
				if (i % 2 == 0)
					for (int j = 0; j < w - 1; ++j)
						maze[i][2 * j + 1] = sc.nextInt();
				else
					for (int j = 0; j < w; ++j)
						maze[i][2 * j] = sc.nextInt();
			Queue<Pair> que = new ArrayDeque<>();
			que.add(new Pair(0, 0));
			maze[0][0] = 1;
			while (que.size() != 0) {
				Pair now = que.poll();
				for (int i = 0; i < 4; ++i) {
					int nx = now.x + dx[i]; int ny = now.y + dy[i];
					if (!((0 <= nx && nx < 2 * h - 1) && (0 <= ny && ny < 2 * w - 1)))
						continue;
					if (maze[now.x + dx[i] / 2][now.y + dy[i] / 2] == 0) {
						if (maze[nx][ny] != -1) continue;
						maze[nx][ny] = maze[now.x][now.y] + 1;
						que.add(new Pair(nx, ny));
					}
				}
			}
			int ans = maze[2 * h - 2][2 * w - 2];
			System.out.println(ans == -1 ? 0 : ans);
		}
	}
}


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

C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)

for n in range(N - 1):
    C[n], S[n], F[n] = map(int, input().split())

for t in range(0, N - 1):
    route_time = S[t]
    for i in range(t, N - 1):
        route_time = route_time + C[i]
        if i != N - 2:
            if route_time >= S[i + 1] and route_time % F[i + 1] == 0:
                continue
            elif route_time >= S[i + 1] and route_time % F[i + 1] != 0:
                route_time = (route_time // F[i + 1]) * F[i + 1] + F[i + 1]
            else:
                route_time = S[i + 1]
    print(route_time)
            
print(0)


Measured memory_bytes: 3188
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    a,b = map(int, input().split())
    for x in range(1250):
        if int(0.08*x) == a and int(0.1*x) == b:
            return x
    return -1

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 5628
#include<iostream>
using namespace std;
int n,d;
struct dian{
    int x,y;
}p[200010];

int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].x,&p[i].y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(1ll*p[i].x*p[i].x+1ll*p[i].y*p[i].y<=1ll*d*d)
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 5380
n,c,k=map(int,input().split())
lista=[int(input())for i in range(n)]
listb=sorted(lista)
count=0
bustime=0
buspeople=0
for i in listb:
    if buspeople==0 or bustime<i:
        count+=1
        buspeople=c-1
        bustime=i+k
    else :
        buspeople-=1
print(count)

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

int main(){
  int N;
  cin >> N;
  int count,a,b;
  count = 0;
  for(int i = 1;i < N +1 ;i++){
    a = N / i;
    b = N % i;
    count += a;
    if(b == 0)count--;
  }

  
  cout << count <<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int>a(n), b(n);
	for(int i=0; i<n; i++){
		int x, y;
		cin >> x >> y;
		a[i] = (x+y);
		b[i] = (x-y);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	cout << max(a[n-1] - a[0], b[n-1] - b[0]) << endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++) ab[i] = make_pair(a[i], b[i]);

    sort(ab.begin(), ab.end());

    long long ans = 0;

    for (int i = 0; i < n; i++) {
        int buy = min(m, ab[i].second);
        ans += (long long)ab[i].first * buy;
        m -= buy;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
bool sosuu(int x){
bool c=true;
int a;
for(int j=2;j*j<=x;j++){
a=x;
a%=j;
if(a==0){c=false; break;}}
if(c)return true;
else return false;}

int main(){
int n;
while(cin>>n){
for(int i=n-1;i>1;i--){
if(sosuu(i)){cout<<i<<" "; break;}}
while(1){
n++;
if(sosuu(n)){cout<<n<<endl; break;}}}}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int a,b,c,d;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b >> c >> d;
	print1((a-c)*(b-d));
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static long mod = 1000000007;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] =sc.nextInt();
		}
		Arrays.sort(a);
System.out.println(a[n-1]-a[0]);



	}
	static int lowerbond(int k, int[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return data[max];
	}


	static long cal(int n){
		long x = (long)n;
		for(int i = n-1;i > 0;i--){
			//	System.out.println(i);
			x *= i;
			x %= mod;
		}
		return x;
	}

}




Measured memory_bytes: 23764
#pragma GCC optimize("O2")
#include<iostream>
using namespace std;
#define f(x,y,z) for(short int x=y;x<z;++x)
bool b[6][6], r[6], c[6];
short int h, w, k, rr[6], cc[6], m, sm, hs, ht;
char x;
void hit(short int z) {
    if(z == h+w) {
        sm = hs = 0;
        f(i,0,h) if(r[i]) sm += rr[i];
        f(j,0,w) if(c[j]) sm += cc[j];
        f(i,0,h) if(r[i]) f(j,0,w) if(c[j] && b[i][j]) ++hs;
        sm -= hs;
        if(sm == ht-k) ++m;
    } else if(z >= h) {
        hit(z+1);
        c[z-h] = true;
        hit(z+1);
        c[z-h] = false;
    } else {
        hit(z+1);
        r[z] = true;
        hit(z+1);
        r[z] = false;
    }
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> h >> w >> k;
    f(i,0,h) f(j,0,w) {
        cin >> x;
        if(x == '.') b[i][j] = false;
        else {
            b[i][j] = true;
            ++rr[i], ++cc[j], ++ht;
        }
    }
    hit(0);
    cout << m << '\n';
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int a=ir.nextInt();
		char s=ir.next().charAt(0);
		int b=ir.nextInt();
		out.println(s=='+'?a+b:a-b);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

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


int main(void){
	
	int x,k=0;
	char data[10];
	int stack[100];
	
	 while( scanf("%s", data) != EOF ){
  		  if ( data[0] == '+' ){
  		  	k--;
  		  		stack[k-1]=stack[k-1]+stack[k];
		}
		else if(data[0]=='-'){
			k--;
			stack[k-1]=stack[k-1]-stack[k];
		}
		else if(data[0]=='*'){
			k--;
			stack[k-1]=stack[k-1]*stack[k];
		}
		else{
			stack[k]=atoi(data);
			k++;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}

	



Measured memory_bytes: 2756
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/2/
Solved on 2019/2/
@author: shinjisu
"""


# ARC 078 C  Splitting Pile
def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def probC():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    sumFormer = A[0]
    sumLatter = sum(A[1:])
    diff = abs(sumFormer-sumLatter)
    dmp(diff,'init')
    for i in range(1, N-1):
        sumFormer += A[i]
        sumLatter -= A[i]
        diff = min(diff, abs(sumFormer-sumLatter))
    return diff


def probC_v1():  # 5/16 AC 残りはTLE
    N = getInt()
    A = getIntList()
    dmp((N, A))
    diff = 10**(9+6)
    for i in range(1, N):
        diff = min(diff, abs(sum(A[:i])-sum(A[i:])))
    return diff


debug = False  # True False
ans = probC()
print(ans)
#for row in ans:
#    print(row)


Measured memory_bytes: 24636
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, a, b = map(int, input().split())
    mod = 10 **9 + 7
    ans = pow(2, n, mod) -1
    c = 1
    for i in range(b):
        c *= n-i
        c%= mod
        c *= pow(i+1, mod-2, mod)
        c %= mod
        if i == a-1:
            ca = c
    ans -= (c+ca)%mod
    ans %= mod
    print(ans)
    





if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
char c[10][10];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>c[i][j];
    ll lim=-1;
    rep(i,h){
        tmp=LINF;
        tmpp=-1;
        rep(j,w){
            if(c[i][j]=='#'){
                tmp=min(tmp,(ll)j);
                tmpp=max(tmpp,(ll)j);
            }
        }
        if(tmpp==-1||lim>tmp){
            Cout("Impossible");
            return 0;
        }
        lim=tmpp;
    }
    Cout("Possible");
    return 0;
}


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

using namespace std;

int main(void){
    int n,i=0,count=0;
    string s;

    cin >> s;
    n = s.length();

    if(n>1){
        do{
            if( s[i] != s[i+1] ){
                    count++;
                    s.erase( s.begin() +i , s.begin() +(i+2) );
                    if(i>0) i--;
                    n = n-2;             
            }else{
                i++;
            }
        }while(n>1 && i<n-1);
    }

    cout << 2*count << endl;

    return 0;
}

Measured memory_bytes: 512
// written by : soumya_27
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define mod ((int)1e9+7)//998244353//((int)1e18+7)
#define M_PI 3.14159265358979323846
// #define maxx ((int)1e7+7)
#define pb push_back
#define ins insert
#define F first
#define S second
#define ins insert
#define pii pair <int , int>
#define lb lower_bound
#define ub upper_bound
#define usefile freopen("input.txt","r",stdin); freopen("ou(tp)ut.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin >> t; while(t--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int exp(int x,int y,int p){ int res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int add(int a, int b) {return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)     
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
using namespace std;
int fact[1000006];
// void facto() {fact[0] = 1; for(i=1 ; i<1000006 ; i++) fact[i] = mul(fact[i-1], i);}
// int ncr(int n, int r) { int res = fact[n]; res = mul(res, inv(fact[r])); res = mul(res, inv(fact[n-r])); return res;}
void solve()
{
    fast
    // test
    {
        int n, i, j, k;
        cin >> n;
        if(n > 29)
        	cout << "Yes\n";
        else cout << "No\n";
        
    }
}

signed main()
{
    // time__("solve")
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3688
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "abc163_b.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int sum = 0;
  REP(i, m) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << (n < sum ? -1 : n - sum) << endl;
}


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  string S, T;
  cin >> S >> T;
  vector<int> s(26), t(26);

  for (char c = 'a'; c <= 'z'; c++) {
    int cnt = count(S.begin(), S.end(), c);
    s[c - 97] = cnt;
    cnt = count(T.begin(), T.end(), c);
    t[c - 97] = cnt;
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  for (int i = 0; i < 26; i++) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  //cout << N;
  int i = 0;
  int ans = 0;

  while (i * 7 <= N) {
    if ((N - i * 7) % 4 == 0) ans++;
    i++;
  }
  if (ans > 0) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a;cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

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

int main() {
    int a,b,c,k, cnt=0;
    cin >> a >> b >> c >>k;
    while(a>=b){
        cnt++;
        b*=2;
    }
    while(b>=c){
        cnt++;
        c*=2;
    }
    if(cnt<=k) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(){
     int a_start, a_finish;
     int b_start, b_finish;
     scanf("%d%d%d%d\n", &a_start, &a_finish, &b_start, &b_finish);
     int vec[101] = {0};

     for (int i = a_start; i < a_finish; ++i)
          ++vec[i];

     for (int i = b_start; i < b_finish; ++i)
          ++vec[i];

     int sum = 0;

     for (int i = 0; i < 100; ++i){
          if (vec[i] == 2)
               ++sum;
     }
     printf("%d\n", sum);


     return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

//エラトステネスの篩
bool isPrime[ (int)1e5 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 2; i <= N; i++ )
    {
        isPrime[ i ] = true;//初期化
    }
    
    isPrime[0] = isPrime[1] = false;

    for( int i = 2; i <= N; i++ )
    {
        if( isPrime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                isPrime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int cumsum[(int)1e5+1] = {};

int main()
{
    Eratosthenes((int)1e5);
    cumsum[0] = 0;
    for (int i=1; i<(int)1e5+1; ++i)
    {
        if(i%2==0)
        {
            cumsum[i] = cumsum[i-1];
            continue;
        }

        if(isPrime[i] && isPrime[(int)(i+1)/2])
        {
            cumsum[i] = cumsum[i-1] + 1;
        }
        else
        {
            cumsum[i] = cumsum[i-1];
        }
        
    }
    int q,l,r;
    cin >> q;
    int ans[q];
    for (int i=0; i<q; ++i)
    {
        cin >> l >> r;
        ans[i] = cumsum[r+1] - cumsum[l-1];
    }
    rep(i,q)
    {
        cout << ans[i] << endl;
    }

    // for (int i=0; i<1000; ++i)
    // {
    //     cout << "i= " << i << " : "<< cumsum[i] << endl;
    // }
    return 0;
}

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

using namespace std;
#define INF (1<<28)
#define MAX_V 101

struct edge{
  int from,to,cost;
};

struct data{
  string o,s;
  int a,b,d;
};

bool isNum(char ch){
  if('0'<=ch&&ch<='9')return true;
  else return false;
}

int s2i(string &str){
  int res=0,i;
  for(i=0;isNum(str[i]);i++){
    res*=10;
    res+=(str[i]-'0');
  }
  str=str.substr(i);
  return res;
}

string s2s(string &str){
  string res="";
  int i;
  for(i=0;!isNum(str[i]);i++){
    res.push_back(str[i]);
  }
  str=str.substr(i);
  return res;
}

int V,E;
vector<edge> G;

vector<data> t;
vector<int> u;


int bellman(){
  int d[MAX_V];
  for(int i=1;i<=V;i++)d[i]=INF;
   d[1]=0;

   for(int I=0;I<V;I++){
     for(int i=0;i<(int)G.size();i++){
       edge e=G[i];
       if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
         d[e.to]=d[e.from]+e.cost;
         if(I==V-1)return -1;
       }
     }
   }

   int res=0;
   for(int i=1;i<=V;i++)res=max(res,d[i]);
   return res;
};


int check(){

  G.clear();
  for(int i=0;i<E;i++){
    data x=t[i];
    if(x.o=="<="&&x.s=="+"){
      G.push_back((edge){x.b,x.a,-x.d});
    }else if(x.o=="<="&&x.s=="-"){
      G.push_back((edge){x.b,x.a,0});
      G.push_back((edge){x.a,x.b,x.d});
    }else if(x.o==">="&&x.s=="+"){
      G.push_back((edge){x.a,x.b,-x.d});
    }else{
      G.push_back((edge){x.a,x.b,0});
      G.push_back((edge){x.b,x.a,x.d});
    }
  }
  for(int i=2;i<=V;i++)
    G.push_back((edge){i,1,0});

  return bellman();
}


void solve(){
  int z=-1;
  int size=u.size();
  for(int S=0;S<(1<<size);S++){
    for(int i=0;i<size;i++){
      int x=u[i];
      if((S>>i)&1)t[x].o="<=";
      else t[x].o=">=";
    }
    z=max(z,check());
  }
  if(z==INF)cout<<"inf"<<endl;
  else cout<<z<<endl;
}

int main(){
  cin>>V>>E;
  t.resize(E);
  for(int i=0;i<E;i++){
    string str;
    cin>>str;
    str.push_back('-');
    t[i].a=s2i(str);
    t[i].o=s2s(str);
    t[i].b=s2i(str);
    t[i].s=s2s(str);
    t[i].d=s2i(str);
    if(t[i].o=="*")u.push_back(i);
  }
  solve();
  return 0;
}

Measured memory_bytes: 1284
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, q;
	cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cin >> q;
	rep(i, q) {
		int b, e, t;
		cin >> b >> e >> t;
		for (int k = 0; k < e - b; k++) {
			swap(a[b + k], a[t + k]);
		}

	}
	rep(i, sz(a)) {
		cout << a[i];
		printf(i == sz(a) - 1 ? "\n" : " ");
	}
}


Measured memory_bytes: 3232
n=int(input())
s=0
for i in range(n):
  s+=i+1
  if s>=n:
    k=i+1
    break
if s==n:
  for i in range(k):
    print(i+1)
else:
  if n==2:
    print(2)
  else:
    for i in range(k):
      if s-i-1!=n:
        print(i+1)
        
  

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
char str[500005];
int q;
int dp[500005][27];
int go[500005][21];
int main(){
	scanf("%s%d",&str,&q); int n = strlen(str);
	rep(i,500005) rep(j,27) dp[i][j] = INF;
	for(int i=0;i<n;i++){
		dp[i][str[i]-'a'] = i;
	}
	{
		bool upd = 0;
		for(int i=n-1;i>=0;i--){
			while(1){
				bool upd = 0;
				for(int j=0;j<=26;j++){
					if(j && dp[i][j-1] < n && dp[dp[i][j-1]+1][j-1] < n && dp[i][j] > dp[dp[i][j-1]+1][j-1]){
						dp[i][j] = dp[dp[i][j-1]+1][j-1];
						upd = 1;
					}
					if(dp[i][26] < n && dp[dp[i][26]+1][j] < n && dp[i][j] > dp[dp[i][26]+1][j]){
						dp[i][j] = dp[dp[i][26]+1][j];
						upd = 1;
					}
				}
				if(!upd) break;
			}
		}
	}
	for(int i=0;i<n;i++){
		go[i][0] = dp[i][26]+1;
		//cout<<i<<" "<<go[i][0]<<endl;
	}
	go[n][0] = n;
	for(int j=0;j<19;j++){
		for(int i=0;i<=n;i++){
			if(go[i][j] >= n) go[i][j+1] = INF;
			else go[i][j+1] = go[go[i][j]][j];
		}
	}
	//cout<<go[0][1]<<endl;
	rep(i,q){
		int x,y; scanf("%d%d",&x,&y); x--;
		for(int i=19;i>=0;i--){
			if(go[x][i] <= y) x = go[x][i];
		}
	//	cout<<x<<" "<<y<<endl;
		puts(x==y?"Yes":"No");
	}
}

Measured memory_bytes: 94848
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

int n;
ll a[10000], b[10000];
ll sa, sb;

int main(){
	cin >> n;
	sa = sb = 0;
	lp(n) {
		cin >> a[i];
		sa += a[i];
	}
	lp(n) {
		cin >> b[i];
		sb += b[i];
	}
	lp(n) {
	if (a[i] < b[i]) {
			sa += ((b[i] - a[i]) % 2 == 0 ? (b[i] - a[i]) / 2 : (b[i] - a[i]) / 2 + 1);
		}
	}
	if (sb >= sa)
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    REP(i, N) cin >> x[i];
    int ans = 0;
    REP(i, N) ans += 2 * min(x[i], K - x[i]);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int a[101];
int k, n, maxn;
int main() {
	cin >> k >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		maxn = max(a[i], maxn);
	}
	int t = maxn - 1;
	if (t <= k - maxn) cout << 0 << endl;
	else cout << t - (k - maxn) << endl;
	
	return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
   int x;
   cin >> x;
   if(x>=30)cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

priority_queue<P,vector<P>,greater<P>> q1;

int main(){
    int n,m;
    int i,j,k;
    int a,b,c;
    int x,y;
    int s=0;
    map<int,LP> m1;
    m1[0]=make_pair(INF,0);
    m1[1]=make_pair(0,0);
    q1.push(make_pair(0,1));
    q1.push(make_pair(INF,0));
    cin>>n>>m;
    for(i=0;i<n;i++){
        cin>>a>>b;
        a--,b++;
        auto itr=m1.upper_bound(b);
        itr--;
        x=itr->second.first,y=itr->second.second;
        if(y==1)x+=b-itr->first;
        m1[b]=make_pair(x,y);
        q1.push(make_pair(x,b));
        itr=m1.upper_bound(a);
        itr--;
        if(itr->second.second==0){
            x=itr->second.first;
            m1[a]=make_pair(x,1);
            q1.push(make_pair(x,a));
        }
        while(1){
            itr=m1.upper_bound(a);
            if(itr==m1.end() || itr->first>=b)break;
            m1.erase(itr);
        }
        while(!q1.empty()){
            x=q1.top().first,y=q1.top().second;
            if(m1.find(y)!=m1.end() && m1[y].first==x && y<=m)break;
            q1.pop();
        }
        if(x<INF)x+=i+1;
        else x=-1;
        cout<<x<<endl;
    }
}

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

#define ll long long
ll gcd(ll a, ll b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
  return a*b/gcd(a,b);
}

int main() {
  ll A,B;
  cin>>A>>B;
  cout<<lcm(A,B)<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1]={};

    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
        else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        //cerr<<dp[i][j]<<endl;
    }

    string res="";
    while(n && m){
        if(dp[n][m]==dp[n-1][m]) n--;
        else if(dp[n][m]==dp[n][m-1]) m--;
        else res=s[n-1]+res,n--,m--;
    }
    

    cout<<res;
}

Measured memory_bytes: 35456