akhauriyash/Code-Regression huggingface dataset:
/* include */
#include <bits/stdc++.h>

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

#define space cout << endl;
#define test_data(data) cout << data << endl;
#define test_comp(var1, var2) cout << var1 << " " << var2 << endl;

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  int begin, end;
  int candy;

  int i, j, k;    // subscript

  int sum_candy;
  int sum, max_sum;
  int down_flag;


  /* Input, Array_Proclamation */
  cin >> N;
  
  vector<int> top   (N, 0);
  vector<int> bottom(N, 0);

  vector<int> top_cum   (N, 0);
  vector<int> bottom_cum(N, 0);

  for(i=0; i<N; i++)
  {
    cin >> top.at(i);
  }
  for(i=0; i<N; i++)
  {
    cin >> bottom.at(i);
  }

  max_sum = 0;
  for(i=0; i<N; i++)
  {

    down_flag = i;
    sum = 0;

    for(j=0; j<N; j++)
    {

      sum += top.at(j);
      if(down_flag == j)
      {
        for(k=i; k<N; k++)
        {
          sum += bottom.at(k);
        }
        break;
      }    

    }
    // test_data(sum);
    max_sum = max(sum, max_sum);

  }

  // space;
  cout << max_sum << endl;
  return 0;


  // // 一段目
  // cin >> begin;
  // for(i=1; i<N; i++)
  // {
  //   cin >> candy;
  //   top.at(i) = candy + top.at(i-1);
  // }
  // // 二段目
  // for(i=1; i<N; i++)
  // {
  //   cin >> candy;
  //   bottom.at(i) = candy + bottom.at(i-1);
  // }
  // cin >> end;

  // space;
  // for(i=0; i<N; i++)
  // {
  //   test_comp(top.at(i), bottom.at(i));
  // }
  // space;

  // return 0;


  // // reverse( all(top) );
  // // reverse( all(bottom) );

  // /* Calculation */
  // sum_candy = 0;
  // for(i=1; i<N; i++)
  // {
  //   // sum_candy = max(sum_candy, )
  // }


  // for(i=1; i<N; i++)
  // {
  //   top_cum.at(i)    = top_cum.at(i-1)    + top.at(N -i -1);
  //   bottom_cum.at(i) = bottom_cum.at(i-1) + bottom.at(N -i -1);
  // }

  // reverse( all(top_cum) );
  // reverse( all(bottom_cum) );

  // // reverse( all(top) );
  // // reverse( all(bottom) );

  // space;
  // for(i=0; i<N; i++)
  // {
  //   test_comp(top.at(i), bottom.at(i));
  // }
  // space;
  // for(i=0; i<N; i++)
  // {
  //   test_comp(top_cum.at(i), bottom_cum.at(i));
  // }
  // space;

  // sum_candy = 0;
  // for(i=0; i<N-1; i++)
  // {
  //   if(top_cum.at(i) < bottom_cum.at(i))
  //   {
  //     sum_candy += bottom_cum.at(i);
  //     cout << "down " << i+1 << endl;
  //     break;
  //   }
  //   else
  //   {
  //     sum_candy += top.at(i);
  //   }

  //   if(i == N-2)
  //   {
  //     cout << "completion" << endl;
  //   }
  // }
  // sum_candy += (begin + end);

  // /* Output */
  // cout << sum_candy << endl;

  // return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 256
#1からスタートして2*K+1個

N,K=map(int,input().split())
S=input()
A=[]

s=1
temp=0
for i in range(N):
    if s!= int(S[i]):
        A.append(temp)
        temp=1
        s=(s+1)%2
    else:
        temp+=1
        
A.append(temp)
if s==0:
    A.append(0)
        
NA=len(A)
if 2*K+1>=NA:
    ans=N
else:
    temp=sum(A[:2*K+1])
    ans=temp
    for i in range(0,NA-2*K-2,2):
        temp=temp-A[i]-A[i+1]+A[i+2*K+1]+A[i+2*K+2]
        ans=max(ans,temp)
        
print(ans)

Measured memory_bytes: 44508
#include <iostream>
#include <cstring>

using namespace std;

int q = 1;
int cell[7][7][7];
int p[7][7][7];
int N;
int M1,M2;
int a[30],b[30];

int main(){
  int c = 0;
  while(1){
    cin >> N;
 

    if(N == 0 ) break;

    memset(cell , 0 , sizeof(cell));
    memset(a , 0 , sizeof(a));
    memset(b , 0 , sizeof(b));
    memset(p , 0 , sizeof(p));

    for(int i = 1; i < 6 ; i++){
      for(int j = 1; j < 6 ; j++){
	int tmp;
	cin >> tmp;
	for(int k = 1 ;k < 6 ; k++){  
	  cell[i][j][6-k] = tmp % 10;
	  tmp /= 10;
	}
      }
    }

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

    cin >> M2;
    for(int i = 0; i < M2 ; i++){
      cin >> b[i];
      //     cout << b[i] << " ";
    }
    //cout << endl;
    while(N){
      // p更新
      memset(p,0,sizeof(p));

      for(int i = 1; i < 6 ; i++){
	for(int j = 1; j < 6 ; j++){
	  for(int k = 1 ;k < 6 ; k++){  

	    if(cell[i][j][k] == 1){
	      for(int t = -1; t <= 1 ; t++){
		for(int s = -1; s <= 1 ; s++){
		  for(int u = -1; u <= 1 ; u++){
		    p[i+t][j+s][k+u]++;
		  }
		}
	      }
	      p[i][j][k]--;
	    }
	  }
	}
      }
 


      //日にちがたつと
      for(int i = 1; i < 6 ; i++){
	for(int j = 1; j < 6 ; j++){
	  for(int k = 1 ;k < 6 ; k++){  

	    if(cell[i][j][k] == 0){
	      for(int s = 0 ; s < M1 ; s++){
		if(p[i][j][k] == a[s]){
		  //		  cout << "IN ";
		  cell[i][j][k] = 1;
		  break;
		}
	      }
	    }
	    else if(cell[i][j][k] == 1){
	      int x = 1;
	      for(int s = 0 ; s < M2 ; s++){
		if(p[i][j][k] == b[s]) x = 0;      
	      }
	      if(x == 1){
		cell[i][j][k] = 0;
	      }
	    }
	  }
	  
	}
      }
    
      N--;    
    }

    //出力 
    if(c != 0) cout << endl;
    c = 1;
    cout << "Case " << q << ":" << endl;
    q++;
    
    for(int i = 1; i < 6 ; i++){
      if(i != 1)
      cout  << endl;
      for(int j = 1; j < 6 ; j++){
	for(int k = 1 ;k < 6 ; k++){  
	  cout << cell[i][j][k];
	}
	cout << endl;
      }
    } 
  }
  
  return 0;
}

Measured memory_bytes: 1168
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [x] <- readInt
  print $ solve x

solve x = a * 1000 + c * 5
 where
  (a, b) = x `divMod` 500
  (c, d) = b `divMod` 5


Measured memory_bytes: 380
import scala.io.{StdIn => in}

object Main extends App {
  val ref = "KIHBR"
  val s = in.readLine
  val ans = if(!s.contains("AA") &&
    !s.contains("KA") &&
    !s.contains("IA") &&
    s.replace("A","") == ref) "YES" else "NO"
  println(ans)
}

Measured memory_bytes: 27336
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
	cin>>a[i];//3
	b[a[i]]=i;//
	}
	for(int i=1;i<=n;i++)
	cout<<b[i]<<' ';
	
}

Measured memory_bytes: 1536
n = int(input())
p = list(map(int, input().split()))

cnt = 0

for i in range(1, n-1):
    if(p[i-1] < p[i] and p[i] < p[i+1]):
        cnt += 1
    elif(p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
N = int(input())
Clist = []
Slist = []
Flist = []
for i in range(N-1):
    C, S, F = map(int, input().split())
    Clist.append(C)
    Slist.append(S)
    Flist.append(F)
    
for i in range(N):
    time = 0
    for j in range(i, N):
        if j != N-1:
            if time <= Slist[j]:
                time = Slist[j] + Clist[j]
            elif time%Flist[j] != 0:
                time = time + Flist[j] - (time%Flist[j]) + Clist[j]
            else:
                time = time + Clist[j]
    print(time)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
double op(double x1,double y1,double x2,double y2){
	return x1*y2-x2*y1;
}

int main(){
	double x[4],y[4];
	while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]){
		double op1 = op(x[1]-x[0],y[1]-y[0],x[3]-x[0],y[3]-y[0]);
		double op2 = op(x[2]-x[1],y[2]-y[1],x[3]-x[1],y[3]-y[1]);
		double op3 = op(x[0]-x[2],y[0]-y[2],x[3]-x[2],y[3]-y[2]);
		if(op1<=0.0 and op2<=0.0 and op3<=0.0) cout << "YES" << endl;
		else if(op1>=0.0 and op2>=0.0 and op3>=0.0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1220
n = int(input())
c = [0]*(n-1)
for i in range(n-1):
    c[i] = list(map(int,input().split()))
for i in range(n-1):
    t = c[i][1]
    for j in range(i,n-1):
        if t <= c[j][1]:
            t = c[j][1]
            t += c[j][0]
        else:
            t +=  -(-t//c[j][2])*c[j][2] - t + c[j][0]
    print(t)
print(0)

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;

class Pool {
	int position;
	int area;
	
	public Pool( int p, int a )
	{
		this.position = p;
		this.area = a;
	}
	public int getPosition( ) 
	{
		return this.position;
	}
	public int getArea( ) 
	{
		return this.area;	
	}
} 

class Main {

    public static void main( String[] args ) {
        try {
	      	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
			String buf = kb.readLine( );
			     
			ArrayDeque<Integer> stack = new ArrayDeque<Integer>( );
			ArrayDeque<Pool> areas = new ArrayDeque<Pool>( );
			int sum = 0;
            for( int i=0; i<buf.length( ); i++ ) {
				if( '\\' == buf.charAt( i ) ) {
					stack.push( Integer.valueOf( i ) );
				} else if( !stack.isEmpty( ) && '/' == buf.charAt( i ) ) {
					int j = stack.pop( ).intValue( );
					int pool = i - j;
					sum += pool;
					while( !areas.isEmpty( ) ) {
						Pool t = areas.getFirst( );
						if( j < t.getPosition( ) ) {
							pool += t.getArea( );
							areas.pop( );
						} else {
							break;
						}
					}
					areas.push( new Pool( j, pool ) );
				}
			}
			
			StringBuilder output = new  StringBuilder( );
			output.append( sum ).append( "\n" );
			output.append( areas.size( ) );
            while( !areas.isEmpty( ) ) {
            	output.append( " " ).append( areas.removeLast( ).getArea( ) );
            }
            System.out.println( output );
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

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

int main(void){
	int k,x;

	scanf("%d %d",&k,&x);
	if(k*500>=x){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,m,k) for(int i=m;i<k;i++)

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0 && m == 0 ) break;

        vector<pair<long long , long long >> v(n);
        rep(i,0,m){
            int s,k;
            cin >> s >> k;
            rep(j,0,k){
                int p;
                cin >> p;
                p--;
                v[p].first += s;
                if(k == 1) v[p].second += s;
            }
        }

        /*
        rep(i,0,n){
            cout << i << ":" << v[i].first << " " << v[i].second << endl;
        }
        */

        long long M = 0 , mi = 0x7FFFFFFF;
        map<int,bool> mp = {};
        rep(i,0,n){
            if( M < v[i].first ){
                mp = map<int,bool> ();
                mp[i] = true;
                M = v[i].first;
            }
            else if(M == v[i].first){
                mp[i] = true;
            }
        }

        rep(i,0,n){
            if( v[i].second < mi&& !mp[i]){
                mi = v[i].second;
            }
        }
        cout << M - mi + 1 << endl;
    }
}



Measured memory_bytes: 3244
import sys
from math import ceil
def main():
    T1, T2, A1, A2, B1, B2 = map(int, sys.stdin.read().split())
    
    # 相対速度
    BA1 = A1 - B1
    BA2 = A2 - B2

    if BA1 == 0:
        print(0)
        sys.exit()

    # A1, B1の速い方をAとする
    if BA1 < 0:
        BA1 = -BA1
        BA2 = -BA2
    
    d = BA1 * T1 + BA2 * T2
    if d > 0:
        print(0)
        sys.exit()
    if d == 0:
        print('infinity')
        sys.exit()
    
    # n: n * d + BA1 * T1 <= 0となる最小の整数
    # d < 0なので
    # n >= (- BA1 * T1) / d
    n = ceil((- BA1 * T1) / d)
    if n * d == - BA1 * T1:
        ans = 2 * n
    else:
        ans = 2 * n - 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

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

signed main() {
	string inp, s;
	while(getline(cin, inp)) {
		s += inp;
	}
	
	const int N = 26;

	for (int i = 0; i < N; ++i) {
		char alp = (char)('a' + i), ALP = (char)('A' + i);
		cout << alp << " : " << count(s.begin(), s.end(), alp) + count(s.begin(), s.end(), ALP) << endl;
	}
}



Measured memory_bytes: 3152
import java.util.*;

class Main {

    public Main(){
        Scanner SC = new Scanner(System.in);
        int N = SC.nextInt();
        long[] X = new long[N];
        long S = 0;

        for(int i=0;i<N;i++){
            X[i] = SC.nextLong();
            S += X[i];
        }

        long P1 = S/N;
        long P2 = S/N+1;

        long R1=0,R2=0;
        for(int i=0;i<N;i++){
            R1 += (X[i]-P1) * (X[i]-P1);
            R2 += (X[i]-P2) * (X[i]-P2);
        }

        System.out.println(Math.min(R1,R2));
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];

  vector<bool> bh(h), bw(w);
  rep(i,h){
    bh[i] = [&]{
      rep(j,w) if(a[i][j]=='#') return true;
      return false;
    }();
  }
  rep(j,w){
    bw[j] = [&]{
      rep(i,h) if(a[i][j]=='#') return true;
      return false;
    }();
  }

  rep(i,h){
    if(!bh[i]) continue;
    rep(j,w) if(bw[j]) cout << a[i][j];
    cout << endl;
  }
}


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

public class Main {

	static int[] ans = new int[1000000];
	static int i;

	// 素数か判別する：素数ならtrue
	//
	public static boolean check(int num) {
		for (int i = 2; i <= Math.sqrt(num); i++) {
			if (num % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num;
		for (i = 0; i < 1000000; i++) { // 入力を読み込む
			int count = 0;
			String str = br.readLine();
			num = Integer.parseInt(str);
			if (num == 0) {
				break;
			} // 読み込みの処理ここまで

			for (int n = num + 1; n <= 2 * num; n++) {
				if (check(n)) {
					count++;
				}
			}
			ans[i] = count;
		} // iのループ

		for (int j = 0; j < i; j++) {
			System.out.println(ans[j]);
		}
	}
}


Measured memory_bytes: 29296
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int elements = sc.nextInt();
        int[] order = new int[elements];
        for (int i = 0; i < elements; i++) {
            order[i] = sc.nextInt()-1;
        }
        int[] point = new int[elements];
        for (int i = 0; i < elements; i++) {
            point[i] = sc.nextInt();
        }
        int[] bonus = new int[elements-1];
        for (int i = 0; i < elements-1; i++) {
            bonus[i] = sc.nextInt();
        }
        
        solve(order,point,bonus);
    }

    public static void solve(int[] order,int[] point,int[] bonus){
        int result = 0;
        int prev = order.length;
        for(int now:order){
            result += point[now];
            if(now-prev==1){
                result += bonus[prev];
            }
            prev = now;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

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

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    char c[h+2][w+2];
    rep(i, h+2)rep(j, w+2) c[i][j] = '#';
    int x, y, dir;
    For(i, 1, h+1)For(j, 1, w+1){
        scanf(" %c", &c[i][j]);
        if(c[i][j] == '>') x = i, y = j, dir = 0;
        if(c[i][j] == 'v') x = i, y = j, dir = 1;
        if(c[i][j] == '<') x = i, y = j, dir = 2;
        if(c[i][j] == '^') x = i, y = j, dir = 3;
    }
    int touch = 1;

    bool visited[h+2][w+2];
    rep(i, h+2)rep(j, w+2) visited[i][j] = false;
    set<pair<pii, pii>> S;
    int ans = 0;
    while(true){
        if(S.find({{x, y}, {dir, touch}}) != S.end()){
            puts("-1");
            return 0;
        }
        S.insert({{x, y}, {dir, touch}});
        if(!visited[x][y]) ++ans, visited[x][y] = true;
        if(c[x][y] == 'G'){
            printf("%d\n", ans);
            return 0;
        }

        if(touch == 0){
            if(c[x + dx[(dir + 1) % 4]][y + dy[(dir + 1) % 4]] == '#'){
                touch = 1;
            }
            else{
                dir = (dir + 1) % 4;
                touch = 2;
            }
        }
        else if(touch == 1){
            if(c[x + dx[dir]][y + dy[dir]] == '#'){
                touch = 3;
            }
            else{
                x += dx[dir];
                y += dy[dir];
                touch = 0;
            }
        }
        else if(touch == 2){
            if(c[x + dx[dir]][y + dy[dir]] == '#'){
                touch = 3;
            }
            else{
                x += dx[dir];
                y += dy[dir];
                touch = 1;
            }
        }
        else{
            dir = (dir + 3) % 4;
            touch = 1;
        }
    }
}


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

typedef long long int ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

	ll x,k,d;
	cin >> x >> k >> d;
	ll stepstozero = abs(x)/d;
	ll ans = 0;
	ans = abs(x)-(stepstozero*d);
	if(stepstozero >= k){
		ans = abs(x)-(k*d);
		cout << abs(ans) << endl;
		return;
	}
	k-=stepstozero;
	if(k&1){
		cout << abs(ans-d) << endl;
	}else{
		cout << abs(ans) << endl;
	}

}

int32_t main()
{
	IOS
	// int T; cin >> T; while (T--)
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
ll l[102];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n;
	cin>>n;
	for (int i = 0; i < n; i++)
	{
		cin>>l[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			for (int k = j+1; k < n; k++)
			{
				if (l[i]!=l[j] and l[i]!=l[k] and l[j]!=l[k] and l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j])
				{
					ans ++ ;
				}
				
			}
			
		}
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27088
#include <stdio.h>

int main(void)
{
	int m,f,b,k;
	scanf("%d %d %d",&m,&f,&b);
	if(m>b){
		printf("0\n");
	}
	else if(m+f>=b){
		k=b-m;
		printf("%d\n",k);
	}
	else printf("NA\n");
	
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define im 2147483647
#define lm 9223372036854775807
#define ll long long
#define vb vector<bool>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define ii pair<int, int>
#define lower_str(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define upper_str(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define debug(index, num) cout << "Case #" << index << ": " << num << endl
#define mx(an, na) an = max(an, na)
#define mn(an, na) an = min(an, na)
#define rep(i, a, b) for (long long i = a; i < b; i++)
#define rep2(i, a, b) for (long long i = a; i <= b; i++)
#define repp(i, a, b) for (long long i = a; i >= b; i--)
#define repp2(i, a, b) for (long long i = a - 1; i >= b; i--)
#define be(x) x.begin(), x.end()
#define rbe(x) x.rbegin(), x.rend()
#define pb push_back
vector<ll> v;
ll maxSum(int n) {
    int tempMax = v[0];
    int currentMax = tempMax;
    for (int i = 1; i < n-1; i++ ) { \
    currentMax = max(v[i], currentMax+v[i]);
    tempMax = max(tempMax, currentMax);
    }
    int f = tempMax;
    tempMax = v[1];
    currentMax = tempMax;
    for (int i = 2; i < n; i++ ) {
    currentMax = max(v[i], currentMax+v[i]);
    tempMax = max(tempMax, currentMax);
    }
return max(f, tempMax);
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >>m >> n;
    vi v(m+10, 0);
    vb vis(m+10, 0);
    ll p = 0, r = 0;
    rep(i, 0, n) {
        ll t; string s;
        cin >> t >> s;
        if(vis[t]) continue;
        else {
            if(s == "AC") {
                r++;
                vis[t] = 1;
            }
            else {
                v[t]++;          
            }
        }
    }
    rep2(i, 1, m) {
        if(vis[i]) {
            p += v[i];
        }
    }
    cout << r <<  " " << p;



    // ll n, m;
    // cin >> n >> m;
    // vector<vector<char>> v(n+2, vector<char> (m+2, '#'));
    // int maxi = 0;
    // int f = 4;
    // rep2(i, 1, n) {
    //     rep2(j, 1, m) {
    //         cin >> v[i][j];
    //     }
    // }
    // vector<ii> g = {{1, 1}, { 1, m}, { n, m}, {n ,1}};
    // while(f--) {
    //     queue<pair<ii, int>> bfs;
    //     vector<vector<bool>> vis;
    //     vis.assign(n+2, vb(m+2, 0));
    //     rep(i, 0, n) {
    //         vis[i][0] = 1;
    //         vis[i][m-1] = 1;
    //     }
    //     rep(j, 0, m) {
    //         vis[0][j] = 1;
    //         vis[n-1][j] = 1;
    //     }
    
    //     bfs.push({g[f], 0});
    //     while(!bfs.empty()) {
    //         int i = bfs.front().first.first;
    //         int j = bfs.front().first.second;
    //         if(v[i][j+1] == '.') bfs.push({{i, j+1}, bfs.front().second + 1});
    //         if(v[i][j-1] == '.') bfs.push({{i, j-1}, bfs.front().second + 1});
    //         if(v[i+1][j] == '.') bfs.push({{i+1, j}, bfs.front().second + 1});
    //         if(v[i-1][j] == '.') bfs.push({{i-1, j}, bfs.front().second + 1});
    //         maxi = max(maxi, bfs.front().second);
    //     }
    // }
    // cout << maxi;
} 

Measured memory_bytes: 640
N, M, Q = list(map(int, input().strip().split()))
pattern_list = []
for _ in range(Q):
    pattern = tuple(map(int, input().strip().split()))
    pattern_list.append(pattern)

def create(N,M):
    S = [[] for _ in range(N+1)]
    for m in range(1,M+1):
        S[1].append([m])
    for n in range(1,N):
        for s in S[n]:
            Max = s[-1]
            for i in range(Max, M+1):
                S[n+1].append(s+[i])
    return S

highest = 0
for letters in create(N,M)[N]:
    point = 0
    for a,b,c,d in pattern_list:
        if c == letters[b-1]-letters[a-1]:
            point += d
    highest = max([highest, point])

print(highest)

Measured memory_bytes: 36112
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	while(n--) {
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second

int main(){
    
    // 1. 入力情報.
    int X, Y, A, B, C;
    scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
    LL x;
    priority_queue<LL> pPQ, qPQ, r, apple;
    rep(i, A){
        scanf("%lld", &x);
        pPQ.push(x);
    }
    rep(i, B){
        scanf("%lld", &x);
        qPQ.push(x);
    }
    rep(i, C){
        scanf("%lld", &x);
        r.push(x);
    }
    
    // 2. X個 の 赤色リンゴ, Y個 の 緑色リンゴ を 保存.
    priority_queue<P, vector<P>, greater<P>> pq;
    int c1 = 0, c2 = 0;
    while(++c1 <= X){
        LL p = pPQ.top();
        pPQ.pop();
        pq.push({p, 1});
    }
    while(++c2 <= Y){
        LL q = qPQ.top();
        qPQ.pop();
        pq.push({q, 2});
    }
    
    // 3. 組み換え.
    // pq の 最小の美味しさのリンゴ と r の 最大の美味しさのリンゴ を 
    // 比較して, 組み換え.
    while(!pq.empty()){
        // pq から 取得.
        P a1 = pq.top();
        
        if(!r.empty()){
            // r から 取得.
            LL a2 = r.top();
            
            // リンゴ a1 が 赤色 の 場合, リンゴ a2 の 美味しさ が 大きい場合, 入れ替え.
            if(a1.b == 1 && X > 0 && a1.a < a2){
                pq.pop();
                pq.push({a2, 3});
                r.pop();
                X--;
                continue;
            }
            
            // リンゴ a1 が 緑色 の 場合, リンゴ a2 の 美味しさ が 大きい場合, 入れ替え.
            if(a1.b == 2 && Y > 0 && a1.a < a2){
                pq.pop();
                pq.push({a2, 3});
                r.pop();
                Y--;
                continue;
            }
        }
        
        // 組み替え出来なかった場合.
        pq.pop();
        apple.push(a1.a);
    }
    
    // 4. 美味しさの集計.
    LL ans = 0;
    while(!apple.empty()){
        LL a = apple.top();
        apple.pop();
        ans += a;
        // printf("%lld\n", a);
    }
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 10092
#include <cstdio>
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
   long long int x,y;
   cin>>x>>y;
   if (y==x)
   cout<<0<<endl;
   else{
      if (y>x)
      {
            long long int ans=abs(abs(x)-abs(y));
            if (x<0&&y>0) ans++;
            cout<<ans<<endl;

      }
      else{   //y<x
             int num=0;
             if (x<0) num++; if (y<0) num++;
             if (num==0) num=2;
             if (y==0) num--;
            long long int ans=abs(abs(x)-abs(y))+num;
            cout<<ans<<endl;
      }
   }
   return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()
ans = 0
max_n = 0
for i in A:
    if i > max_n:
        max_n = i
    else:
        ans = ans + (max_n - i)
print(ans)

Measured memory_bytes: 102488
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

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

signed main(){
    IOS;
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) return cout << 0, 0;
    int n = (2*x - y) / 3;
    int m = (2*y - x) / 3;
    if (m < 0 || n < 0) return cout << 0, 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = ans * ((m+i) * power(i, MOD-2) % MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,M;
    cin >> N >> M;

    vector<int> A(M);
    rep(i,M) cin >> A[i];

    ll total = 0;
    rep(i,M) total += A[i];
    
    if( N >= total ) cout << N-total << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
void a(){

}

void b(){
    string s;cin >> s;
    string sf = s.substr(0,s.size()/2);
    string bsf = sf;
    reverse(bsf.begin(),bsf.end());
    string sb = s.substr((s.size()+1)/2);
    string bsb = sb;
    reverse(bsb.begin(),bsb.end());
    if(sf==bsf&&bsf==sb&&sb==bsb){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
}

void c(){
    double l;
    cin >> l;
    cout << fixed << setprecision(10)<<l/3*l/3*l/3;
}


void d(){
    ll n; cin >> n;
    auto a = v<>(n,0);
    auto m = map<int,ll>();
    

    rep(i,n) {
        cin >> a[i];
        m[a[i]]++;
    }
    ll kai =0;
    for(auto i:m){
        kai+= i.second*(i.second-1)/2;
    }
    rep(i,n){
        cout << kai -m[a[i]]*(m[a[i]]-1)/2 + (m[a[i]]-1)*max((ll)0,(m[a[i]]-2))/2 << endl; 
    }
}
int main(){
    d();
    return 0;
}


Measured memory_bytes: 11912
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    string S;
    cin >> S;
    if(S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  lnt long long int
#define dbl double
using namespace std;


int main()
{

    lnt n;
    cin>>n;
    vector<lnt> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    lnt ans=0;
    for(int i=0;i<n;i++)
    {   
        if(i==0)
        {
            ans-=arr[i];
        }
        else if(i!=n-1)
        {
            ans+=abs(arr[i]);
        }
        else
        {
            ans+=(arr[i]);
        }
    }
    cout<<ans<<endl;
    lnt o=arr[0];
    for(int i=1;i<n-1;i++)
    {
        if(arr[i]>=0)
        {   
            cout<<o<<" "<<arr[i]<<endl;
            o-=(arr[i]);
        }
        else
        {
            cout<<arr[n-1]<<" "<<arr[i]<<endl;
            arr[n-1]-=arr[i];
        }

    }
    cout<<arr[n-1]<<" "<<o;
}









Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int H,A;
	cin>>H>>A;
	int ans;
	ans=H/A + (H%A?1:0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

int insertionSort(V<int> &A, const int &n, const int &h) {
    int cnt = 0;
    FOR(i, h, n) {
        int v = A[i];
        int j = i - h;
        while(j >= 0 && A[j] > v) {
            A[j + h] = A[j];
            j -= h;
            cnt++;
        }
        A[j + h] = v;
    }
    return cnt;
}

int shellSort(V<int> &A, const int &n) {
    V<int> h;
    int x = 3;
    while((x - 1) / 2 <= n) {
        h.push_back((x - 1) / 2);
        x *= 3;
    }
    reverse(ALL(h));
    cout << h.size() << endl;
    int cnt = 0;
    rep(i, h.size()) {
        if(i) cout << " ";
        cout << h[i];
        cnt += insertionSort(A, n, h[i]);
    }
    cout << endl;
    return cnt;
}

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

    int n;
    cin >> n;
    V<int> A(n);
    rep(i, n) cin >> A[i];
    cout << shellSort(A, n) << endl;
    rep(i, n) cout << A[i] << endl;

    return 0;
}


Measured memory_bytes: 6760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		long ans = 0;
		int ans2 = 0;

		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
//		long  k = sc.nextLong();
//		longd = sc.nextInt();
//
//		boolean f = false;
		int[] a = new int[n-1];
		for (int i = 0; i < n-1; i++) {
			a[i] = sc.nextInt();
		}
//		int[] b = new int[n+1];
//		int[] c = new int[n+1];
//		for (int i = 1; i <n+1; i++) {
//			b[i] = sc.nextInt();
//		}
//		for (int i = 1; i <n; i++) {
//			c[i] = sc.nextInt();
//		}

		int chash = 0;

		for(int i = 0; i < n;i++) {
			if(i==0) {
				ans2 += a[i];
			} else if(i==n-1) {
				ans2 += a[i-1];
			} else {
				if(a[i] < a[i-1]) {
					ans2 += a[i];
				} else {
					ans2 += a[i-1];
				}
			}
		}


		System.out.println(ans2);

		sc.close();
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
 
using namespace std;
 
 
int main(){
    int count[10001],tmp,num=3;
    for(int i=0;i<10001;i++)count[i]=0;
 
    for(int i=0;i<10;i++){
        scanf("%d",&tmp);
        count[tmp]++;
    }
 
    for(int i=10000;i>=0&&num>0;i--){
        if(count[i]>0){
            for(int k=0;k<count[i]&&num>0;k++){
                printf("%d\n",i);
                num--;
            }
        }
    }
 
    return 0;
}


Measured memory_bytes: 2796
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;

  int ans = 0;
  rep(n, 1, N + 1){
    if(n % 2 == 0) continue;
    int num = 0;
    rep(i, 1, n + 1){
      if(n % i == 0) num++;
    }
    if(num == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#define N 55
using namespace std;

int n, m, cnt;
int dr[4] = {-1, 1, 0, 0}, dc[4] = {0, 0, -1, 1};
struct st {
	int r, c, z;
};
queue<st> qu;
char a[N][N];
bool v[N][N];
void f(int p, int q, int w) {
	if (v[p][q] || a[p][q] != '.') return;
	v[p][q] = 1;
	qu.push({p, q, w});
}
int main()
{
	int i, j;
	st t;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%s", &a[i][1]);
		for (j = 1; j <= m; j++) if (a[i][j] == '#') cnt++;
	}
	f(1, 1, 1);
	while (!qu.empty()) {
		t = qu.front(); qu.pop();
		if (t.r == n && t.c == m) break;
		for (i = 0; i < 4; i++) {
			f(t.r + dr[i], t.c + dc[i], t.z + 1);
		}
	}
	if (t.r == n && t.c == m) cout << n * m - cnt - t.z;
	else cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(ALL(A));
  ll minus = A.at(0);
  ll plus = A.at(N-1);
  vector<Pll> ans(0);
  for(int i = 1; i < N-1; i++){
    if(A.at(i) >= 0){
      ans.push_back(Pll(minus, A.at(i)));
      minus -= A.at(i);
    }
    else{
      ans.push_back(Pll(plus, A.at(i)));
      plus -= A.at(i);
    }
  }
  ans.push_back(Pll(plus, minus));
  cout << plus - minus << endl;
  for(auto x: ans) cout << x.first << ' ' << x.second << endl;
}

Measured memory_bytes: 4336
// created on : Sun Jun 14 2020
 
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        int x = in.nextInt();
        int n = in.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++){
            set.add(in.nextInt());
        }
        int ans = MAX;
        int diff = MAX;
        for(int i = -10; i < 110; i++){
            if(!set.contains(i)){
                int d = Math.abs(i - x);
                if(d < diff){
                    ans = i;
                    diff = d;
                }
            }
        }
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void displayRuntime(long startTime){
        long stopTime = System.currentTimeMillis();
        long elapsedTime = stopTime - startTime;
        System.out.println("Runtime: " + elapsedTime / 1000D);
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


Measured memory_bytes: 25468
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static long ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {
		//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//		String W	 = in.readLine();
		//		int num = Integer.parseInt(W.split(" ")[0]);

		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();
		}
		ans = 1000;
		for(int i = 0;i<N-1 ; i++) {
			if(A[i+1]> A[i]) {
				ans += (ans/A[i])*A[i+1]-(ans/A[i])*A[i];
			}else {
				continue;
			}
		}



		System.out.println(ans);
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 35892
# import itertools
# import math


def solve(N, M):
    return 'Yes' if N == M else 'No'


# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, M))


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
int main(){
	int size, k, *dp, arr[100000], i, x, val;
	scanf("%d%d", &size, &k);
	for(i=0;i<size;i++)
		scanf("%d", &arr[i]);
	dp = (int*)malloc(sizeof(int)*size);
	for(i=0;i<size;i++){
		if(i>k){
			dp[i] = 1000000000;
			for(x=1;x<=k;x++){
				val = dp[i-x]+abs(arr[i-x]-arr[i]);
				dp[i] = dp[i]<val?dp[i]:val;
			}
		}else
			dp[i] = abs(arr[0] - arr[i]);
			
	}
	printf("%d", dp[size-1]);
	return 0;
}



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

int main() {
	int N, M, X, Y, x[100], y[100];
	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}
	sort(x, x + N, greater<int>());
	sort(y, y + M);
	if (x[0] < y[0] && X < y[0] && x[0] < Y) cout << "No War" << endl;
	else cout << "War" << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
table = [1] + [0] * 2020
exp = [1]
for i in range(N):
    exp += [exp[-1]*10 %2019]

curr = 0
for i in range(N):
    curr += int(S[N-1-i])*exp[i]
    curr %= 2019
    table[curr] += 1

ans = 0
for i in table:
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 81004
#include<iostream>
#include<string>
#include<stdio.h>
#include <string.h>

using namespace std;

int main() {
	int N, H, W;
	int a, b;
	int count = 0;

	scanf("%d%d%d", &N, &H, &W);

	for (int i = 0; i < N; i++)
	{
		scanf("%d %d", &a, &b);
		if (a >= H && b >= W)count++;
	}
	printf("%d\n", count);
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;


int main(){
  string S;
  cin >> S;
  bool ok = true;
  for(int i = 0; i < S.size()-1; i++){
    for(int j = i+1; j < S.size(); j++){
      if(S[i] == S[j]) ok = false;
    }
  }
  if(ok) cout << "yes" <<endl;
  else cout << "no" <<endl;

}
  


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
/* ex2_3
	kanon */

#include <stdio.h>

int main(void) {
  //与えられる値を入れる変数を宣言
  int Number,Area;
  
  //変数に値を入力する
  scanf("%d",&Number);
  scanf("%d",&Area);
  
  //N×NマスーAマス（答え）を出力
  printf("%d\n",Number*Number-Area);
  
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int x[] = new int[3];
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
		}

		int tmp = 0;
		int max = 0;
		for (int i = 0; i < 3; i++) {
			tmp = 0;
			for (int j = 0; j < x.length; j++) {
				if (i == j) {
					tmp += x[j] * 10;
				} else {
					tmp += x[j];
				}
			}

			max = Math.max(tmp, max);
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 23764