akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>


int main(void){
	int i;
	char str[21];
	
	for(i=0;i<21;++i){
		str[i] = '\0';
	}
	
	scanf("%s",&str);
	
	for(i=20;i>=0;--i){
		if(str[i]!='\0'){
			printf("%c",str[i]);
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 0
function Main(s){
  s = s.split("\n");
  var n = +s[0];
  var a = s[1].split(" ").map(a=>+a);
  for(var i = 0; i < n; i++){
    a[i] -= i;
  }
  a.sort((a,b)=>a-b);
  var k = a[(n/2)|0];
  var ans = 0;
  for(i = 0; i < n; i++){
    ans += Math.abs(a[i] - k);
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 38656
using System;
using System.Collections.Generic;
class Program
    {
        static int name2num(string s)
        {
            int ret = 0;
            foreach (char c in s)
            {
                ret *= 4;
                ret += "ATCG".IndexOf(c);
            }
            return ret;
        }
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int A = 0, T = 1, C = 2, G = 3;
            long[] arr = new long[64];
            arr[name2num("TTT")] = 1;
            for (int i=0; i<n; i++)
            {
               long[] buf = new long[64];
               for (int j=0; j<64; j++)
               {
                   if (j%16 == name2num("AAG"))
                   {
                       foreach(char c in "ATG") buf[name2num("AG" + c.ToString())] += arr[j]; 
                   }
                   else if (j%16 == name2num("AAC"))
                   {
                       foreach(char c in "ATC") buf[name2num("AT" + c.ToString())] += arr[j];
                   }
                   else if (j%16 == name2num("AGA"))
                   {
                       foreach(char c in "ATG") buf[name2num("GA" + c.ToString())] += arr[j];
                   }
                   else if (j/16 == A && j%4 == G)
                   {
                       foreach(char c in "ATG") buf[j*4%64 + name2num(c.ToString())] += arr[j]; 
                   }
                   else if (j/4 == name2num("AG"))
                   {
                       foreach(char c in "ATG") buf[j*4%64 + name2num(c.ToString())] += arr[j]; 
                   }
                   else
                   {
                       foreach(char c in "ATGC") buf[j*4%64 + name2num(c.ToString())] += arr[j];
                   }
               }
               arr = buf;
               for (int j=0; j<64; j++) buf[j] = buf[j] % 1000000007;
            }
            long ans = 0;
            foreach (long i in arr) ans = (ans + i) % 1000000007;
            Console.WriteLine(ans);
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int N;
vector<int> s;
int main()
{
  cin>>N;
  int sc=0,sum=0;
  for (int i=0;i<N;i++)
  {
    int x;
    cin>>x;
    if (x%10) {sum+=x;s.push_back(x);}
    else sc+=x;
  }
  sort(s.begin(),s.end());
  if (sum%10) cout<<sc+sum<<endl;
  else 
  {
    if (s.size()==0) puts("0");
    else 
      cout<<sc+sum-s[0]<<endl;
  }
  //system("pause");
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        final boolean[][] shops = new boolean[n][10];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                shops[i][j] = scanner.nextInt() == 1;
            }
        }

        final int[][] profits = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                profits[i][j] = scanner.nextInt();
            }
        }

        System.out.println(recursive(new boolean[10], 0, shops, profits));
    }

    private static int recursive(final boolean[] isOpen, final int index, final boolean[][] shops, final int[][] profits) {
        if (index == 9) {
            return Math.max(calc(true, isOpen, shops, profits), calc(false, isOpen, shops, profits));
        } else {
            isOpen[index] = true;
            int trueValue = recursive(isOpen, index + 1, shops, profits);

            isOpen[index] = false;
            int falseValue = recursive(isOpen, index + 1, shops, profits);

            return Math.max(trueValue, falseValue);
        }
    }

    private static int calc(final boolean bool, final boolean[] isOpen, final boolean[][] shops, final int[][] profits) {
        if (isAllFalse(isOpen)) {
            return Integer.MIN_VALUE;
        }
        isOpen[9] = bool;
        return IntStream.range(0, shops.length)
                .map(i -> {
                    final boolean[] shop = shops[i];
                    int tmp = (int) IntStream.range(0, shop.length)
                            .filter(j -> isOpen[j] && shop[j])
                            .count();
                    return profits[i][tmp];
                }).sum();
    }

    private static boolean isAllFalse(final boolean[] isOpen) {
        return IntStream.range(0, isOpen.length)
                .mapToObj(i -> isOpen[i])
                .noneMatch(Boolean::booleanValue);
    }
}


Measured memory_bytes: 47068
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
int main() {
	int a[6], sum[5] = {0};
    int i = 0;
    while(1){
        std::cin >> a[i];

        if (a[i] == 0) {
            break;
        }
		i++;
        
    }
	i = 0;
    while (a[i] != 0) {
        sum[i] += (1000 - a[i]) / 500;
        a[i] = (1000 - a[i]) % 500;
        sum[i] += a[i] / 100;
        a[i] = a[i] % 100;
        sum[i] += a[i] / 50;
        a[i] = a[i] % 50;
        sum[i] += a[i] / 10;
        a[i] = a[i] % 10;
        sum[i] += a[i] / 5;
        a[i] = a[i] % 5;
        sum[i] += a[i];
        i++;
    }
    for (int j = 0; j<i; j++) {
        std::cout << sum[j] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3080
# AGC038B
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


from queue import deque
from collections import defaultdict
n, k = map(int, input().split())
p = list(map(int, input().split()))

count = 0
q = deque([])
maxq = deque([])
ren = 0
prev = -1
es = defaultdict(set)
slist = []
for i,num in enumerate(p):
    if i>=k:
        m = p[q[0]]
        M = p[maxq[0]]
        if num>M and m==p[i-k]:
            count += 1
            es[i-k].add(i-k+1)
            es[i-k+1].add(i-k)

    if prev<num:
        ren += 1
        prev = num
        if ren>=k-1:
            slist.append(i-k+1)
    else:
        ren = 0
        prev = num
    
    while q and p[q[-1]]>num:
        q.pop()
    q.append(i)
    if q[0]<=i-k:
        q.popleft()
    while maxq and p[maxq[-1]]<num:
        maxq.pop()
    maxq.append(i)
    if maxq[0]<=i-k:
        maxq.popleft()
if len(slist)>=2:
    for i in range(len(slist)-1):
        es[slist[i]].add(slist[i+1])
        es[slist[i+1]].add(slist[i])
ans = 0   
seen = [False] * n
for i in range(n-k+1):
    if seen[i]:
        continue
    ans += 1
    q = [i]
    seen[i] = True
    while q:
        u = q.pop()
        for v in es[u]:
            if not seen[v]:
                q.append(v)
                seen[v] = True
print(ans)    

Measured memory_bytes: 128332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, N, count;
  cin >> H >> N;
  count = 0;
  vector<int> data(N);
  for (int i = 0; i < N; i++){
    cin >> data.at(i);
    count += data.at(i);
  }
  if (count >= H ){
    cout << "Yes" <<endl;
  }
  else cout << "No" << endl;
}
  

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();
        for (int i = 0; i < N; i++) {
            int num = sc.nextInt();
            if(num % 2 == 0){
                if(num % 3 != 0 && num % 5 != 0){
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 22996
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int counter =0;
		int num = sc.nextInt();
		int x =1;
		while (x <= num ) {
			counter = counter + x;
			x++;
		}
		System.out.println(counter);
	}
}


Measured memory_bytes: 35620
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = set(map(int, input().split()))

for i in range(1000):
  a = X - i
  if a not in p:
    print(a)
    exit()

  a = X + i
  if a not in p:
    print(a)
    exit()


Measured memory_bytes: 9180
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var a = ScanInt(); // ... 4, 2, 1, 4
      int idx = 1;
      while(true){
        if(a == 4 || a == 2 || a == 1) break;
        a = a%2==0 ? (a/2) : (3*a+1);
        idx++;
      }
      WriteLine(idx+3);
    }
  }
    
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
 
#define ll long long
#define MAX 1000000007
 
using namespace std;
 
ll am[100002];
ll bm[100002];
ll factrial_division[100002] = {};

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll ans = 1;
    while (n > 0) {
        if (n & 1) ans = ans * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
   return modpow(a, mod - 2, mod);
}

//n個からk個を選ぶ場合の数
ll select(int n, int k, ll *p){
   if(n == 0 || k > n){
      return 0;
   }else if(n == k){
      return 1;
   }else{
      p[k] = p[k-1] * (n - k + 1) % MAX;
      if(factrial_division[k] == 0) factrial_division[k] = factrial_division[k - 1] * modinv(k, MAX) % MAX;
      return p[k] * factrial_division[k] % MAX;
   }
}
 
int main(){
   int n, a, flag = 0, mid;
   ll ans;
 
   cin >> n;
   vector<int> memo(n + 1, -1);
   for(int i = 0; i < n + 1; i++){
      cin >> a;
      if(flag == 0){
         if(memo[a] == -1){
            memo[a] = i;
         }else{
            mid = i - memo[a] + 1;
            flag = 1;
         }
      }
   }

   //初期化
   am[1] = n + 1;
   bm[0] = 1;
   factrial_division[0] = 1;
   factrial_division[1] = 1;

   cout << n << endl;
   for(int i = 2; i <= n + 1; i++){
      ans = select(n + 1, i, am) - select(n + 1 - mid, i - 1, bm);
      if(ans < 0) ans += MAX;
      cout << ans << endl;
   }
}

Measured memory_bytes: 5852
<?php
  while ($line = fgets(STDIN)) {
   $array[] = trim($line);
  }
  $count = 0;
  $n = (int)$array[0];
  $figure = explode(" ", $array[1]);
  
  for($i = 0; $i < $n; $i++) {
   $figure[$i] = (int)$figure[$i];
  }
  
  while(true) {
    $flag = false;
    for($i = 0; $i < $n; $i++) {
     if($figure[$i] % 2 != 0) $flag = true; 
    }
    
    if($flag) break;
    
    for($i = 0; $i < $n; $i++) {
     $figure[$i] /= 2; 
    }
    
    $count++;
  }
  echo($count);



Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int X;
    cin >> X;
    for(int i = -1000; i <= 1000; i++) {
        for(int j = -1000; j <= 1000; j++) {
            if(pow(i,5)-pow(j,5) == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4080
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

int main()
{
    int t[100], p[100], x[100];
    int n, m;

    cin >> n;
    REP(i, n) cin >> t[i];
    cin >> m;
    REP(i, m) cin >> p[i] >> x[i];

    REP(i, m)
    {
        int sum = x[i];
        REP(j, n)
        {
            if(j + 1 == p[i]) continue;
            sum += t[j];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define num 19
using namespace std;

int main() {
    string s;
    cin >> s;
    for (int tmp = 0; tmp < num; tmp++){
        if (s[tmp] == ','){
            s[tmp] = ' ';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
    while(1) {
        int N, M;
        cin >> N >> M;
        if(!N && !M) break;
 
        int v[N];
        int pos = 0;
        for(int i = 0; i < N; ++i) {
            cin >> v[i];
        }
        int m[M];
        for(int i = 0; i < M; ++i) {
            cin >> m[i];
        }
        for(int i = 0; i < M; ++i) {
            pos += m[i];
            if(pos >= N-1) {
                cout << (i+1) << endl;
                break;
            }
            pos += v[pos];
            if(pos >= N-1) {
                cout << (i+1) << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3080
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1e5+5;
int fa[N],id[N],a[N],vis[N],ins[N],n,m,sum;ll res;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	scanf("%d%d",&n,&m),sum=(n-1-m)<<1;
	if(sum>n)return puts("Impossible"),0;
	fp(i,1,n)scanf("%d",&a[i]),fa[i]=id[i]=i;
	sort(id+1,id+1+n,[](const int &x,const int &y){return a[x]<a[y];});
	for(R int i=1,u,v;i<=m;++i)scanf("%d%d",&u,&v),fa[find(u+1)]=find(v+1);
	if(sum)fp(i,1,n)if(!vis[find(id[i])])ins[i]=vis[find(id[i])]=1,res+=a[id[i]],--sum;
	fp(i,1,n)if(sum&&!ins[i])res+=a[id[i]],ins[i]=1,--sum;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		boolean[] buttons = new boolean[n];
		int count = 0;
		int next = 1;
		while (true) {
			if (buttons[next - 1]) {
				break;
			}
			if (next == 2) {
				System.out.println(count);
				return;
			}
			buttons[next - 1] = true;
			next = arr[next - 1];
			count++;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 51812
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

  val Array(n, m, k) = scala.io.StdIn.readLine().split(" ").map(_.toLong)
  val A = scala.io.StdIn.readLine().split(" ").map(_.toLong)
  val B = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve() = {
    val cumulativeA = A.scan(0L)(_ + _)
    val cumulativeB = B.scan(0L)(_ + _)

    var j = m.toInt
    (0 to n.toInt).foldLeft(0) { (acc, i) =>
      if(cumulativeA(i) <= k) {
        while(cumulativeB(j) > k - cumulativeA(i))
          j -= 1
        Math.max(acc, i+j)
      } else acc
    }
  }


  println(solve())

}



Measured memory_bytes: 94308
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> arr = new ArrayList<Integer>();
		arr.add(scanner.nextInt());
		arr.add(scanner.nextInt());
		arr.add(scanner.nextInt());
	    Collections.sort(arr);
		System.out.println(arr.get(0) + arr.get(1));
	}
}


Measured memory_bytes: 21844
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: String,
    }
    let c = c.bytes().next().unwrap();
    println!("{}", (c + 1) as char);
}



Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);


//入力変数
int A=sc.nextInt();
int B=sc.nextInt();


//入力値変換


//出力変数
int ans=0;

//計算
int ma =A/10000;
int sa =(A-ma*10000)/1000;
int ha =(A-ma*10000-sa*1000)/100;
int a =ma*10000+sa*1000+ha*100+sa*10+ma;
int mb =B/10000;
int sb =(B-mb*10000)/1000;
int hb =(B-mb*10000-sb*1000)/100;
int b =mb*10000+sb*1000+hb*100+sb*10+mb;

if(a>=A&&B>=b){
    ans=B/100-A/100+1;
}else if(a<A&&B>=b){
    ans=B/100-A/100;
}else if(a>=A&&B<b){
    ans=B/100-A/100;
}else if(a<A&&B<b){
    ans=B/100-A/100-1;
}

//出力
System.out.println(ans);

}}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
const int MOD = 1000000007; // 10^9 + 7
const double PI = 3.14159265358979323846;
const int N = 10000000; // 10^7
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for (auto& i:v) cin>>i;
    sort(v.begin(),v.end());
    auto ans=0;
    for (int i=0; i<k; ++i) ans+=v[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	// int t;
	// while(){
		scanf("%d",&n);
		int ans=10-n/200;
		cout<<ans<<endl;
	// }
}

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

int main(){
  int N;
 cin>>N;
  vector<pair<int,int>> A(N);
   for(int i=0;i<N;i++){
    int a;
    cin>>a;
     A.at(i)=make_pair(a,i);
   }
  sort(A.begin(),A.end());
  
  for(int i=0;i<N;i++){
    int a;
    tie(ignore,a)=A.at(i);
    cout<<a+1<<" ";
  }
  cout<<endl;
}

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

int main(int argc, char* argv[])
{
	int i,j;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			cout<<i<<"x"<<j<<"="<<i*j<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1116
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_added=[0]
b_added=[0]
for i in range(n):
    a_added.append(a_added[i]+a[i])
for i in range(m):
    b_added.append(b_added[i]+b[i])

ans=0
j=m
for i in range(n+1):
    if a_added[i]>k:
        break
    while b_added[j]>k-a_added[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

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

typedef long long ll;
typedef long double ld;
const ll M=1e9+7;
const ll MAXN=1e6+7;
const ld pi=acos(-1);

#define gi(n) ll n=read()
#define endl '\n'
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define per(i,a,b) for(ll i=b-1; i>=a; --i)

typedef vector<ll> V;
typedef vector<V> VV;
typedef set<ll> S;
typedef pair<ll,ll> pl;
typedef vector<pl> Vp;

#define all(v) v.begin(),v.end()
#define pb push_back
#define fs first
#define sc second

inline ll read(){
	ll x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll pow1(ll p,ll d, ll P){return d?(pow1(p*p%P,d>>1,P)*(d&1?p:1))%P:1;}

V prime;
bool is_composite[MAXN];
void sieve (ll n){
	std::fill (is_composite, is_composite + n, false);
	rep(i,2,n){
		if(!is_composite[i]) prime.pb(i);
		for(ll j = 0; j < prime.size() && i*prime[j] < n; ++j){
			is_composite[i*prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}
ll modInverse(ll a, ll m){
	ll m0=m,y=0,x=1;
	if(m==1) return 0;
	while(a>1){
		ll q=a/m,t=m;
		m=a%m;
		a=t; 
		t=y;

		y = x-q*y; 
		x = t;
	}
	if(x<0) x += m0;
	return x; 
}

void doit(){
	gi(x);
	cout<<360/gcd(x,360);
}
int main(){
//	for(gi(t);t--;cout<<endl)
		doit();
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

#include <set>

multiset<int> s;
int n;

int main()
{
	cin >> n;

	REP(_i, n)
	{
		int a; cin >> a;

		auto it = s.lower_bound(a);
		if (it != s.begin())
			s.erase(--it);
		
		s.insert(a);
	}

	cout << s.size() << endl;
}


Measured memory_bytes: 4992
<?php
fscanf(STDIN, "%d %d", $N, $M);
// N:偶数 M:奇数
$ans = 0;
// 偶＋偶＝偶
$ans += $N * ($N - 1) / 2;
// 奇＋奇＝偶
$ans += $M * ($M - 1) / 2;

printf("%d", $ans);


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

void sieve(int n,vector<char>& v){
    v.resize(n);
    fill(v.begin(),v.end(),true);
    v[0]=v[1]=false;

    for(int i=2;i*i<=n;i++){
        if(v[i]){
            for(int j=2*i;j<=n;j+=i){
                v[j]=false;
            }
        }
    }
}

int main(){
    vector<char> prime_list;
    int n;

    sieve(60000,prime_list);
    while(cin>>n){
        int s,b;
        for(s=n-1;!prime_list[s];s--);
        for(b=n+1;!prime_list[b];b++);

        cout<<s<<" "<<b<<endl;
    }

    return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main() {
  long long int x;
  cin>>x;
 
  for(long long int i=0;i<1000;i++){
    long long int a5=1;
    rep(k,0,5){a5*=i;}
    for(long long int j=-1000;j<1000;j++){
      long long int b5=1;
      rep(l,0,5){b5*=j;}
      if(a5-b5==x){cout<<i<<" "<<j<<endl;return 0;}
    }
  }
  //cout<<"No";
  return 0;
}

Measured memory_bytes: 3632
N=int(input())
S=[]
for i in range(N):
    s=int(input())
    S.append(s)
t=set([0])
for i in range(N):
    t_=set()
    for s in t:
        t_.add(s)
        t_.add(s+S[i])
    t=t_
ans=0
for s in t:
    if s%10==0:
        continue
    ans=max(s,ans)
print(ans)


Measured memory_bytes: 4628
#include <stdio.h>
#include <math.h>

long long Move(long long N){
  long long i;
  for(i = (long long) sqrt(N);i > 1;i--) if(N % i == 0) break;
  return i + N / i - 2;
}

int main(void){
  long long N;
  scanf("%lld", &N);
  printf("%lld\n", Move(N));
  return 0;
}


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

int main()
{
  string str;
  cin >> str;
  for (int i = 0; i < str.size(); i++){
    if (str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e'){
      str.replace(i, 5, "peach");
    }
    else if (str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h'){
      str.replace(i, 5, "apple");
    }
  }
  cout << str;
  while (cin >> str){
    for (int i = 0; i < str.size(); i++){
      if (str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e'){
        str.replace(i, 5, "peach");
      }
      else if (str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h'){
        str.replace(i, 5, "apple");
      }
    }
  cout << " " << str;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,K,d=0,x[100];
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	for(int j=0;j<N;j++){
		if(K-x[j]<x[j])d=d+(K-x[j]);
		else d=d+x[j];
	}
	cout<<2*d;
}

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

string s, t, ans;
int dp[3005][3005];

int main()
{
	cin >> s >> t;
	s = "@" + s;
	t = "#" + t;
	
	int n = s.size() - 1;
	int m = t.size() - 1;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)	
			if(s[i] == t[j])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else 
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
	
	while(n > 0 and m > 0)
	{
		if(dp[n][m] == dp[n - 1][m])
			n--;
		else if(dp[n][m] == dp[n][m - 1])
			m--;
		else
			ans.push_back(t[m]), n--, m--;		
		
	}
	reverse(ans.begin(), ans.end());
	
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 35456
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
count = 0
L.sort()
for i in range(N):
    for j in range(i):
        m = L[i] - L[j]
        k = bisect_right(L, m)
        n = max(0, j - k)
        count += n
print(count)


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

using namespace std;

const int N = 100010;
bool flag[N];
int wa[N], ac[N];
queue<int> q;

int main()
{
	int n, m;
	int ac1(0), wa1(0);
	cin>>n>>m;
	while(m -- )
	{
		string st;
		int num;
		cin>>num;
		cin >> st;
		if(st == "AC") 
		{
			if(!flag[num]) 
			{
				flag[num] = 1;
				q.push(num);
				ac1 ++;
			}
		}
		if(st == "WA")
		{
			if(!flag[num]) 
			{
				wa[num] += 1;
			}
		}
	}
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		wa1 += wa[u];
	}
	cout<<ac1<<" "<<wa1;
	return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<iostream>
#define gmax(x, y) if ((y) > x) x = (y);
using namespace std;
typedef long long ll;
inline char nc() {
	static char b[1<<12],*s=b,*t=b;
	return s==t&&(t=(s=b)+fread(b,1,1<<12,stdin),s==t)?-1:*s++;
}
template < class T >
inline void read(T &x) {
	char b = nc(); x = 0;
	for (; !isdigit(b); b = nc());
	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';
}
inline ll read() {
	char b = nc();
	for (; b != '-' && b != '+'; b = nc());
	return b == '-' ? -1 : 1;
}
int n;
ll f0, f1, f2;
int main() {
	read(n); read(f0); f1 = f2 = -1e15;
	for (int a, op, i = 1; i < n; ++i) {
		op = read(); read(a);
		f0 += a * op; f1 -= a * op; f2 += a * op;
		if (op == -1) {
			gmax(f2, f1); gmax(f1, f0);
		} gmax(f1, f2); gmax(f0, f1);
	} printf("%lld\n", f0);
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	deque<int> res;
	res.push_back(a[0]);
	rrep(i, n) {
		int it = lower_bound(all(res), a[i]) - res.begin();
		if (!it) res.push_front(a[i]);
		else res[it - 1] = a[i];
	}
	dunk(res.size());
	return 0;

}

Measured memory_bytes: 1024
import numpy as np

s = np.array(list(input()))
t = np.array(list(input()))
dp = np.zeros((len(s) + 1, len(t) + 1), dtype=int)

is_eq = s[:, None] == t[None,]
for i in range(len(s)):
    dp[i + 1, 1:] = np.maximum(dp[i, :-1] + is_eq[i], dp[i, 1:])
    dp[i + 1] = np.maximum.accumulate(dp[i + 1])

i, j = len(s), len(t)
ans = ''
while i > 0 and j > 0:
    if dp[i, j] == dp[i - 1, j]:
        i -= 1
    elif dp[i, j] == dp[i, j - 1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1
print(ans[::-1])


Measured memory_bytes: 91592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    int n;
    cin >> n;
    string s[n];
    map<string , int> m;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> s[i];
        m[s[i]]++;
    }
    int max1 = -1;
    for(auto it : m)
    {
        max1 = max(max1 , it.ss);
    }
    set<string> vec;
    for(auto it : m)
    {
        if(it.ss == max1)vec.insert(it.ff);
    }
    for(auto it : vec)
    {
        cout << it << endl;
    }
    return 0;
}

Measured memory_bytes: 36224
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

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

(A, B, C, K) = reads()

print((A - B) * (-1) ** (K % 2))


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i = 0; i<n;i++){
    cin >> v[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(v[0]-v[1]);
  int x;
  for(int i = 2; i<n;i++){
    x = INT_MAX;
    for(int j = 0; j<k && j<i;j++){
      x = min(x,abs(v[i]-v[i-j-1])+dp[i-j-1]);
    }
    dp[i] = x;
  }
  cout << dp[n-1]<<'\n';
  return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

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

int main(void){
    ll dp[100010], h[100010];
    REP(i, 100010) dp[i] = INF;

    int n; cin >> n;
    REP(i, n) cin >> h[i];

    dp[0] = 0;

    FOR(i, 1, n){
        chmin(dp[i], dp[i - 1]  + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << endl;
}

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

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int n;
	cin >> n;

	int a[n];
	F0R(i,n) cin >> a[i];

	int ud[n];
	ud[0] = 0;
	FOR(i,1,n) {
		if(a[i-1] <= a[i]) ud[i] = 1;
		else ud[i] = 0;
	}

	// D2(ud);
	bool ok = 0;
	int take, cnt = 1000;
	FOR(i,1,n) {
		// D1(cnt);
		if(ud[i] == 1) cnt += (a[i] - a[i-1]) * (cnt/a[i-1]);
		
	}
	cout << cnt;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3808
import sys


N = int(input())

H = list(map(int,input().split()))

dp = [float('inf')]*N

dp[0] = 0
#print(N)
#print(H)
#print(dp)


for i in range(1,N):
    if(i==1):
        dp[1] = abs(H[1]-H[0])
    else:
        dp[i] = dp[i-1]+abs(H[i]-H[i-1])
        if(dp[i] > dp[i-2]+abs(H[i]-H[i-2])):
            dp[i] = dp[i-2]+abs(H[i]-H[i-2])
        #
        #print(i,dp)

print(dp[-1])

#7
#2 9 4 5 1 6 10


Measured memory_bytes: 13908
use proconio::input;

fn main() {
    input! {
        n: usize,
        x: isize,
        xx: [isize; n],
    }

    let xx = xx.into_iter().map(|e| e - x).collect::<Vec<_>>();

    let mut ans = xx[0];

    for x in xx {
        ans = gcd(ans, x);
    }

    println!("{}", ans.abs());
}

fn gcd(a: isize, b: isize) -> isize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

Measured memory_bytes: 4464
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))




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

signed main(){
  VI a(3); rep(i,3) cin>>a[i]; sort(ALL(a));
	if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2])){
		return cout<<"Yes"<<endl,0;
	}
	cout << "No" << endl;
  return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  cout << sum - N << endl;

}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
using namespace std;

int main()
{
    array<int, 3> s;
    int cou = 0;
    cin >> s[0] >> s[1] >> s[2];
    // sort using the default operator<
    
    sort(s.begin(), s.end());
    
    while(s[2] - s[0] > 1){
        s[0] += 2;
        sort(s.begin(), s.end());
        cou++;
    }
    if(s[0]==s[2]){
        
    }else if(s[0]==s[1]){
        cou++;
    }else{
        cou += 2;
    }
        
    cout << cou << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std ;

int ans = 0 ;

bool answer( int n ,long num[] ,int p )
{
	if( n == num[ p ] )
	{
		ans++ ;
		return true ;
	}
	return false ;
}

int main()
{
	int s ,t ,n ;

	cin >> s ;
	long num[ s ] ;

	for( int i = 0 ; i < s ; i++ )
		cin >> num[ i ] ;

	cin >> t ;
	for( int i = 0 ; i < t ; i++ )
	{
		int p = 0 ,pp = s ;
		bool br = false ;
		cin >> n ;
		while( true )
		{
			int a = p + ( ( pp - p ) / 2 ) ;
			if( answer( n ,num ,a ) )
				break ;
			else if( n > num[ a ] )
			{
				if( answer( n ,num ,a + 1 ) )
					break ;
				p = a + 1 ;
				if( p == pp )
					break ;				
			}
			else if( answer( n ,num ,a - 1 ) )
				break ;
			else
			{
				pp = a - 2 ;
				if( pp <= p )
					break ;
			}
		}
	}

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 3876
n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
lastR = -1
for i in range(n):
	if cFixed[i] == "R":
		lastR = i
ans = 0
for i in range(lastR+1):
	if c[i] == "W":
		ans += 1

print(ans)


Measured memory_bytes: 88032
H, W, A, B = map(int, input().split())
matr = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
  for w in range(W):
    if w >= A and h >= B:
      matr[h][w] = 1
    if w < A and h < B:
      matr[h][w] = 1
    

for h in range(H):
  for w in range(W):
    print(matr[h][w], end = '')
  print() 

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

int main() {
	int datas[100] = { 0 };
	int num,biggest_num=0;
	while (cin >> num) {
		datas[num-1]++;
	}
	for (int i = 0; i < 100; i++) {
		if (biggest_num < datas[i]) {
			biggest_num = datas[i];
		}
	}
	for (int i = 0; i < 100; i++) {
		if (biggest_num == datas[i]) {
			cout << i + 1<<endl;
		}
	}
	return 0;
}

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

int main() {
  int nAlpha[26] = {0};
  string s;
  cin >> s;
  for (int i=0; i<(int)s.length(); i++) {
    int n = (int)(s[i]-'a');
    nAlpha[n]++;
  }

  string ans = "None";
  for (int i=0; i<26; i++) {
    if (nAlpha[i] == 0) {
      ans = i+'a';
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n,m;
	cin >> n >> m;
	int a[m],b[m];
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
	}
	
	int ichi[n]={0},ni[n]={0};
	for(int i=0;i<m;i++){
		if(a[i]==1){
			ichi[b[i]] = 1;
		}
		if(b[i]==n){
			ni[a[i]] = 1;
		}
	}
	
	for(int i=0;i<n;i++){
		if(ichi[i]*ni[i]==1){
			cout << "POSSIBLE" << endl;
			break;
		}
		if(i==n-1) cout << "IMPOSSIBLE" << endl;
	}
	
	
	
	return 0;
}

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

int main(){
  int x,y;
  cin >>x >>y;
  if(y-2*x>=0 && 4*x>=y && (y-2*x)%2==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  string S_i;

  READ(N);

  // main procedure
  set<string> strings_set;

  for (size_t i = 0; i < N; ++i) {
    READ(S_i);
    strings_set.insert(S_i);
  }

  size_t ans = strings_set.size();

  // output
  WRITE_N(ans);

  return 0;
}


Measured memory_bytes: 19272
#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h,w,a):
    da = [[0]*w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1,w):
        da[0][i] = da[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(da,p,q,x,y):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

def examD():
    N, K = LI()
    #y=0,x=0上で、原点とおなじグループかどうか
    colorXY = [[0] * (2*K) for _ in range(2*K)]
    for _ in range(N):
        #原点の色を白(0)とする
        x, y, c = LSI()
        x, y = int(x), int(y)
        if c=="B":
            y +=K
        colorXY[x%(2*K)][y%(2*K)] +=1
    ans = 0
    ansC = N
    da = da_generate(2*K, 2*K, colorXY)
    for i in range(K):
        for j in range(K):
            cur = da_calc(da,0,0,K-i-1,K-j-1) + da_calc(da,K-i,K-j,2*K-i-1,2*K-j-1)\
                + da_calc(da,0,2*K-j,K-i-1,2*K-1) + da_calc(da,2*K-i,0,2*K-1,K-j-1)\
                + da_calc(da,2*K-i,2*K-j,2*K-1,2*K-1)
            ans = max(ans,cur)
            ansC = min(ansC,cur)
    print(max(ans,N-ansC))

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 108380
N = int(input())
H = [float('inf')] + list(map(int, input().split()))
DP = [0] * (N+1)

for i in range(2, N+1):
    DP[i] = min(abs(H[i] - H[i-1]) + DP[i-1], abs(H[i] - H[i-2]) + DP[i-2])
print(DP[N])


Measured memory_bytes: 20440
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define mx          10000000

bool vis[10000010];
vector<ll>prime;//, div;
void sieve()
{
    vis[0]=vis[1]=1;

    for(int i=2; i<=mx; i++)
    {
        if(vis[i]==0)
        {
            prime.push_back(i);
            for(int j=i*2; j<=mx; j+=i)
                vis[j]=1;
        }
    }
}
ll div_count(ll n)
{
    ll div=1;
    for(int i=0; i<prime.size() &&  prime[i]*prime[i]*prime[i]<=n; i++)
    {
        if(n%prime[i]==0)
        {
            ll cnt=0;
            while(n%prime[i]==0)
            {
                cnt++;
                n/=prime[i];
            }
            div*=cnt+1;
        }
    }
    //cout<<div<<" "<<n<<endl;
    if(n>1)
    {
        if(vis[n]==0)
            div*=2;
        else
        {
            ll p=sqrt(n);
            if(p*p==n && vis[p]==0)
                div*=3;
            else
                div*=4;

        }
    }
    return div;
}

vector<ll>v;
int main()
{
    ll m,n,j, cnt=0;
    cin>>n;
    sieve();

    ll ff=0;
    for(ll i=1; i<=n; i++)
    {
        if(n==1) ff=1, v.push_back(ff);
        else ff=div_count(i),  v.push_back(ff);
    }


   ll ans=0;
    for(int i=0; i<n; i++) ans+=v[i]*(i+1);
        //cout<<v[i]<<" ";
    cout<<ans<<endl;

}




Measured memory_bytes: 149440
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, i;
  cin >> a >> b;
  vector<string> art(100);
  for(i=0;i<a;i++) {
    cin >> art.at(i);
  }
  for(i=0;i<b+2;i++) {
    cout << "#";
  }
  cout << endl;
  for(i=0;i<a;i++) {
    cout << "#" << art.at(i) << "#" << endl;
  }
  for(i=0;i<b+2;i++) {
    cout << "#";
  }
  cout << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(br.readLine().replaceAll("apple", "\0").replaceAll("peach", "apple").replaceAll("\0", "peach"));
	}
}

Measured memory_bytes: 16900