akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int sx,sy,tx,ty;
    //sとtを２往復しなければならない
    scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
    int i,j;
    for(i=0;i<tx-sx;i++){
        printf("R");
    }
    for(i=0;i<ty-sy;i++){
        printf("U");
    }
    for(i=0;i<tx-sx;i++){
        printf("L");
    }
    for(i=0;i<ty-sy;i++){
        printf("D");
    }
    printf("D");
    for(i=0;i<tx-sx+1;i++){
        printf("R");
    }
    for(i=0;i<ty-sy+1;i++){
        printf("U");
    }
    printf("L");
    printf("U");
    for(i=0;i<tx-sx+1;i++){
        printf("L");
    }
    for(i=0;i<ty-sy+1;i++){
        printf("D");
    }
    printf("R\n");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        struct Point_t
        {
            internal double x;
            internal double y;
        }

        static StringBuilder sb = new StringBuilder();

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Point_t a, b;
            a.x = 0.0;
            a.y = 0.0;
            b.x = 100.0;
            b.y = 0.0;
            
            sb.AppendLine(string.Format("{0:f8} {1:f8}", a.x, a.y));
            Koch(n, a, b);
            sb.AppendLine(string.Format("{0:f8} {1:f8}", b.x, b.y));

            Console.Write(sb);
        }

        static void Koch(int n,Point_t a,Point_t b)
        {
            if (n == 0) return;
            
            double rd = Math.PI * 60.0 / 180.0;

            Point_t s, t, u;
            s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
            s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
            t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
            t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
            u.x = (t.x - s.x) * Math.Cos(rd) - (t.y - s.y) * Math.Sin(rd) + s.x;
            u.y = (t.x - s.x) * Math.Sin(rd) + (t.y - s.y) * Math.Cos(rd) + s.y;

            Koch(n - 1, a, s);
            sb.AppendLine(string.Format("{0:f8} {1:f8}", s.x, s.y));
            Koch(n - 1, s, u);
            sb.AppendLine(string.Format("{0:f8} {1:f8}", u.x, u.y));
            Koch(n - 1, u, t);
            sb.AppendLine(string.Format("{0:f8} {1:f8}", t.x, t.y));
            Koch(n - 1, t, b);
        }
    }
}

Measured memory_bytes: 9864
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np
 
n = int(input())
a = [int(i) for i in input().split()]
 
#print(a)
a = np.sort(a)
ai = a[n-1]
aj = a[0]
center = ai / 2
diff = ai
i=0
for m in a:
    if diff > abs(m - center) :
        aj = m
        diff = abs(aj - center)
    else:
        break
 
print(ai,aj)

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

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

int f(int a){
   int ans = 0;
   while (a%2==0){
      a /= 2;
      ans++;
   }
   return ans; 
}


int main(){
   ll n,m; 
   cin >> n >> m;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];

   rep(i,n){
      if(a[i]%2==1){
         cout << 0 << endl;
         return 0;
      }
      a[i] /= 2;
   }

   int t = f(a[0]);
   rep(i,n){
      if(f(a[i])!=t){
         cout << 0 << endl;
         return 0;
      }
      a[i] >>= t;
   }
   m >>= t;

   ll l = 1;
   rep(i,n){
      l = lcm(l, a[i]);
      if(l > m){
         cout << 0 << endl;
         return 0;
      }
   }

   m /= l;
   int ans = (m+1)/2;
   cout << ans << endl;
   return 0;  
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int dif = ab[1] - ab[0];

        //差がdifとなるとき、bの本来の高さはdif
        int realB = Enumerable.Range(1, dif).Sum();

        Console.WriteLine(realB - ab[1]);

    }
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		for(int i=0;i<n;i++) {
			int cost = sc.nextInt();
			int y = sc.nextInt();
			int m = sc.nextInt();
			int ans = cost;
			for(int j=0;j<m;j++) {
				int th = sc.nextInt();
				double r = sc.nextDouble();
				int yr = sc.nextInt();
				int tmp = cost;
				int rr = 0;
				if( th == 0 ) {
					for(int k=0;k<y;k++) {
						rr += r*tmp;
						tmp -= yr;
					}
					tmp += rr;
					ans = max(ans, tmp);
				}
				else {
					for(int k=0;k<y;k++) {
						tmp += r*tmp-yr;
					}
					ans = max(ans, tmp);
				}
			}
			System.out.println(ans);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
a = LIST()
res  = 1
if 0 in a:
    print(0)
    sys.exit()

for i in range(n):
    res *= a[i]
    if res > 10**18:
        print(-1)
        sys.exit()
print(res)

Measured memory_bytes: 87128
N = int(input())
R = [[int(i) for i in input().split()] for i in range(N)]
B = [[int(i) for i in input().split()] for i in range(N)]

R,B = sorted(R, key=lambda x: x[1])[::-1],sorted(B)

answer = 0
for i in B:
    for j in R:
        if i[0]>j[0] and i[1]>j[1]:
            answer += 1
            R.remove(j)
            break
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <stdint.h>
#include <cstring>
#include <map>
using namespace std;
int main(void) {
	int n;
	int count[100000];
	std::map<int,int> mp;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> count[i];
	for (int i = 0; i < n; i++)mp[count[i]] = i;
	int ans = 0;
	int i = 0;
	for (std::map<int,int>::iterator x = mp.begin(); x != mp.end(); x++) {
		ans += abs(x->second - i) % 2;
		i++;
	}
	ans /= 2;
	cout << ans << endl;
}

Measured memory_bytes: 5376
S = input()
ch = ['A','C','G','T']

ans = 0
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        s = S[i:j]
        flag = 0
        for ss in s:
            if not (ss in ch):
                flag = 1
                break
        if flag == 0:
            ans = max(ans, len(s))

print(ans)


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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  int w = n - 1;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  function<int64(int)> solve_d = ([&](int d) {
    int64 ans = 0;
    int l = 0;
    int r = w;
    int64 current = 0;
    while (true) {
      l += d;
      r -= d;
      if (l > w || r < 0) break;
      if (r <= d) break;
      if (w % d == 0 && r <= l) break;
      current += xs[l];
      current += xs[r];
      ans = max(ans, current);
    }
    return ans;
  });

  int64 ans = 0;
  for (int d = 1; d <= w; d++) {
    ans = max(ans, solve_d(d));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int len = s.length();
    long long ans = 0;
    for (int i = 0; i < (1 << len - 1); i++) {
        long long sum = 0;
        long long tmp = 1;
        for (int j = 0; j < len; j++) {
            sum += tmp * (s[len - 1 - j] - '0');
            if (!(i & (1 << j))) {
                tmp *= 10;
            } else {
                tmp = 1;
            }
        }
        ans += sum;
//        cout << sum << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a=[int(input()) for i in range(5)]
b= [(a[i]+10-1)%10 for i in range(5)]

n=b.index(min(b))
p=a.pop(n)
c=[(a[i]+10-1)//10*10 for i in range(4)]
m=sum(c)+p
print(m)
  

Measured memory_bytes: 38384
#include <stdio.h>
int main()
{
    int N,K;
    scanf("%d %d",&N,&K);
    if(K==0){
        printf("%d",0);
    }else if(N%K==0){
        printf("%d",0);
    }else{
        printf("%d",1);
    }
    return 0;
}


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

using namespace std;

int n,dem,res;
char a[200010];

int main()
{
    cin>>n;
    dem=0;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        if (a[i]=='R') dem++;
    }
    res=dem;
    for (int i=1; i<=dem; i++)
        if (a[i]=='R') res--;
    cout<<res;
}


Measured memory_bytes: 3792
s = input()
q = int(input())
l = [input().split() for _ in range(q)]

for i in range(q):
    a = int(l[i][1])
    b = int(l[i][2])
    if l[i][0] == "replace":
        s = s[:a] + l[i][3] + s[b+1:]
    elif l[i][0] == "reverse":
        if a == 0:
            s = s[b::-1] + s[b+1:]
        else:
            s = s[:a] + s[b:a-1:-1] + s[b+1:]
    else:
        print(s[a:b+1])


Measured memory_bytes: 5624
N, Q = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

ans = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

from collections import deque

visited = [False]*N
d = deque([0])
while len(d)>0:
    v = d.popleft()
    visited[v]= True
    for u in edge[v]:
        if visited[u]==False:
            ans[u] += ans[v]
            visited[u]=True
            d.append(u)

print(*ans, sep=' ')

Measured memory_bytes: 105364
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll dp[2010][2010];
int n;
ll d[2010];
int main(){
  cin>>n;
  lol(i,n)cin>>d[i];
  lol(i,n)lol(j,n)dp[i][j]=0;
  lol(i,n)dp[i][i]=d[i];
  lol(k,n-1){
    lol(r,n){
      int i=r,j=(r+k)%n;
      int a=(i+n-1)%n,b=(j+1)%n;
      if(k%2==0){
	if(d[a]>d[b])dp[a][j]=max(dp[a][j],dp[i][j]);
	if(d[a]<d[b])dp[i][b]=max(dp[i][b],dp[i][j]);
      }
      if(k%2==1){
	dp[a][j]=max(dp[a][j],dp[i][j]+d[a]);
	dp[i][b]=max(dp[i][b],dp[i][j]+d[b]);
      }
    }
  }
  ll ans=0;
  lol(i,n)lol(j,n)ans=max(ans,dp[i][j]);
  cout<<ans<<endl;
  return 0;
}

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

#define INIT_CAP 100

typedef struct Queue {
    int count;
    int capacity;
    int tail;
    int head;
    int *data;
} Queue;

static inline void q_init(Queue* q) {
    q->count = 0;
    q->capacity = INIT_CAP;
    q->tail = 0;
    q->head = 0;
    q->data = (int *)malloc(sizeof(int) * INIT_CAP);
}

static inline void q_double(Queue *q) {
    q->capacity *= 2;
    q->data = (int *)realloc(q->data, sizeof(int) * q->capacity);
}

static inline void q_enqueue(Queue *q, int x) {
    if (q->head >= q->capacity) {
        q_double(q);
    }
    
    q->count++;
    q->data[q->head++] = x;
}

static inline void q_dequeue(Queue *q) {
    if (q->count == 0) return;
    q->count--;
    q->tail++;
}

static inline void q_front(Queue *q) {
    if (q->count == 0) return;
    printf("%d\n", q->data[q->tail]);
}

int test() {
    Queue queue;
    q_init(&queue);
    
    q_dequeue(&queue);
    q_front(&queue);
    q_enqueue(&queue, 1);
    q_enqueue(&queue, 2);
    q_enqueue(&queue, -3);
    q_front(&queue);
    q_dequeue(&queue);
    q_dequeue(&queue);
    q_enqueue(&queue, -100);
    q_front(&queue);
    q_dequeue(&queue);
    q_front(&queue);
    return 0;
}

int main(void){
    int count = 0;
    int n, q, query, t, x;
    char a[20];
    
    FILE *fp;
    fp = stdin;
    /*
    if ((fp = fopen("./input.txt", "r")) == NULL) {
        printf("Fail to open ./input.txt\n");
        exit(1);
    }
    
    */
    
    fgets(a, 20, fp);
    sscanf(a, "%d %d", &n, &q);
    
    Queue Q[n];
    for (int i=0; i<n; i++) {
        Queue queue;
        q_init(&queue);
        Q[i] = queue;
    }
    
    while (q--) {
        count++;
        fgets(a, 20, fp);
        sscanf(a, "%d %d %d", &query, &t, &x);
        switch (query) {
            case 0:
                q_enqueue(&Q[t], x);
                break;
            case 1:
                q_front(&Q[t]);
                break;
            case 2:
                q_dequeue(&Q[t]);
                break;
            default:
                printf("Invalid query: %d\n", query);
                exit(1);
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <numeric>

using namespace std;

vector<int> line_to_array(istream& is, const int cnt, const char sep);
vector<string> split(const string &str, const char sep);
string trim(const string& str, const char* trimCharacterList  = " \t\v\r\n");
bool chk_rcsv(int j, int k, char** t, bool** chk_t, string str, int pos);

int main(){
    //ifstream cin("inputAB55_1.txt");
    
    int N;
    int x,y;
    
    string str;
    vector<string> words;
    
    getline(cin, str);
    trim(str);
    N = atoi(str.c_str());
    
    x = 800 * N;
    y = 200 * (N / 15);

    cout << x-y << endl;
    
    return 0;
}

vector<int> line_to_array(istream& is, const int cnt, const char sep){
    vector<int> v;
    string str;
    getline(is, str);
    vector<string> words = split(str, sep);
    for (int i=0; i < cnt; i++) {
        v.push_back( atoi(words[i].c_str()) );
    }
    return v;
}

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

string trim(const string& str, const char* trimCharacterList)
{
    string result;
    string::size_type left = str.find_first_not_of(trimCharacterList);
    
    if (left != string::npos)
    {
        string::size_type right = str.find_last_not_of(trimCharacterList);
        result = str.substr(left, right - left + 1);
    }
    return result;
}


Measured memory_bytes: 256
import math
[a,b,h,m]=[int(i) for i in input().split(' ')]

angposmin=6*m
angposhour=(60*h+m)/2


m=min(a,b)
M=max(a,b)

angdiff=(2*math.pi*abs(angposmin-angposhour)/360)
diff= M-(math.cos(angdiff)*m)
# print("ang",diff)
p=math.sin(angdiff)*m

# print(p)
print(math.sqrt(diff*diff+p*p))

Measured memory_bytes: 9588
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1 for _ in range(N)]
visited[0] = 0
k = 0
k = A[k] - 1
count = 0
while visited[k] == -1:
  count += 1
  visited[k] = count
  k = A[k]-1
 
roop = count - visited[k] + 1
beforeroop = visited[k]
 
if K < beforeroop:
  k = 0
  for _ in range(K):
    k = A[k] - 1
  print(k+1)
else:
  K = K - beforeroop
  K = K % roop
 
  for _ in range(K):
    k = A[k]-1
  print(k+1)

Measured memory_bytes: 98948
def magic(n):
    c=1
    x=n/2
    y=x+1
    while 1:
        A[y][x]=c
        if c==n*n:break
        while 1:
            x,y=(x+1)%n,(y+1)%n
            if A[y][x]==0:break
            x,y=(x-1)%n,(y+1)%n
            if A[y][x]==0:break
        c+=1
    return
while 1:
    n=input()
    if n==0:break
    N=range(n)
    A=[[0]*n for i in N]
    magic(n)
    for i in N:
        print "".join(["%4d"%(e)for e in A[i]])

Measured memory_bytes: 4244
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn main(){
    let n: usize = get_one();
    let xs: Vec<i64> = get_vec();
    let fs: Vec<i64> = cumgcd(&xs);
    let bs: Vec<i64> = cumgcd_rev(&xs);
    let mut ans = bs[1];
    for i in 1..(n as i64 - 1) as usize {
        let j = (i as i64 - 1) as usize;
        let k = i+1;
        ans = max(ans, gcd(fs[j], bs[k]));
    }
    ans = max(ans, fs[(n as i64 - 2) as usize]);
    println!("{}", ans);
}

fn cumgcd(xs: &Vec<i64>) -> Vec<i64> {
    let mut fs_temp = vec![];
    for &x in xs {
        if let Some(&l) = fs_temp.last() {
            fs_temp.push(gcd(x, l));
        } else {
            fs_temp.push(x);
        }
    }
    fs_temp
}

fn cumgcd_rev(xs: &Vec<i64>) -> Vec<i64> {
    let mut fs_temp = vec![];
    for &x in xs.iter().rev() {
        if let Some(&l) = fs_temp.last() {
            fs_temp.push(gcd(x, l));
        } else {
            fs_temp.push(x);
        }
    }
    fs_temp.iter().rev().map(|&x| x).collect()
}


fn gcd(x: i64, y: i64) -> i64 {
    if x % y == 0 {
        y
    } else {
        gcd(y, x % y)
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  vector<int> a(5);
  int mi = 10, ans = 0;
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
      ans += 10;
    } else {
      ans += ((a[i] - 1) / 10 + 1) * 10;
    }
    cerr << ans << '\n';

    a[i] %= 10;
    if (a[i] != 0) {
      mi = min(mi, a[i]);
    }
  }
  if (mi != 10) {
    ans -= (10 - mi);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>

int main(void){
  int a[26],i;
  char s[27];
  bool ans=false;

  scanf("%s",s);

  for(i=0;i<26;i++)
    a[i]=0;

  for(i=0;s[i]!=0;i++){
    a[s[i]-'a']++;
    if(a[s[i]-'a']==2){
      ans=true;
      break;
    }
  }

  if(ans==true)
    printf("no\n");
  else
    printf("yes\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll ans = 0;
    ll mi = LLONG_MAX;
    for (ll i = 0; i < s.size() - 1; i++)
    {
        if (s[i] != s[i + 1])
        {
            ll temp = max(i + 1, (ll)(s.size() - i - 1LL));
            if (mi > temp)
            {
                mi = temp;
                ans = temp;
            }
        }
    }
    if (ans == 0)
    {
        ans = s.size();
    }

    cout << ans << endl;
}


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

string field[1000];
int H, W;
long long mod = 1e9 + 7;
long long dp[1001][1001];


int main(){
    cin >> H >> W;
    for(int h = 0; h < H; h++){
        cin >> field[h];
    }
    dp[1][1] = 1;

    for(int h = 1; h <= H; h++){
        for(int w = 1; w <= W; w++){
            if(field[h - 1][w - 1] == '.'){
                dp[h][w] += dp[h - 1][w] + dp[h][w - 1];
                dp[h][w] %= mod;
            }
        }
    }

    cout << dp[H][W] << endl;
}

    


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

int main() {
  	int a, b, c;
    cin >> a >> b >> c;
    if ((100*a+10*b+c)%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
		if(xa1 <= xb2 && xb1 <= xa2 && ya1  <= yb2 && yb1 <= ya2) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1220
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int A = 0;
		int B = 0;
		for(int i=n; i>0; i-=2){
			A += a[i];
			B += a[i-1];
		}
		System.out.println(A-B);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
	int n, coun, ans = 0;
	string h;
	cin >> n >> h;
	for (int i = 1; i < n; ++i) {
		string mon = h.substr(0, i), mmon = h.substr(i);
		coun = 0;
		for (char j = 'a'; j <= 'z'; ++j) {
			if (mon.find(j) != -1 && mmon.find(j) != -1) { ++coun; }
		}
		ans = max(ans, coun);
	}
	cout << ans << endl;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> A(N,0);
    for(int i=0;i<N-1;i++){
        int index_joshi;
        cin>>index_joshi;
        A.at(index_joshi-1)++; 
    }
    for(int i=0;i<N;i++){
        cout<<A.at(i)<<endl;
    }
}

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

int main()
{
    string s;
    cin >> s;
    if(s[0]=='S' && s[1]=='U' && s[2]=='N')
    cout << 7;
    else if(s[0]=='M' && s[1]=='O' && s[2]=='N')
    cout << 6;
    else if(s[0]=='T' && s[1]=='U' && s[2]=='E')
    cout << 5;
    else if(s[0]=='W' && s[1]=='E' && s[2]=='D')
    cout << 4;
    else if(s[0]=='T' && s[1]=='H' && s[2]=='U')
    cout << 3;
    else if(s[0]=='F' && s[1]=='R' && s[2]=='I')
    cout << 2;
    else if(s[0]=='S' && s[1]=='A' && s[2]=='T')
    cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n);
	for (int i = 0; i < n + 1; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
	}
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		int ai = a[i], aii = a[i + 1], bi = b[i];
		b[i] -= a[i];
		if (b[i] <= 0) {
			sum += bi;
		}
		else {
			a[i + 1] -= b[i];
			if (a[i + 1] <= 0) {
				sum += (ai + aii);
				a[i + 1] = 0;
			}
			else {
				sum += bi;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	unsigned long long int x[5000];
	int n,a,b,i,nan,k;
	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		k=0;
		for(i=0;i<5000;i++) x[i]=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nan,&a,&b);
			x[nan]+=a*b;
			if(x[nan]>999999){
				printf("%d\n",nan);
				k++;
			}
		}
		if(k==0) printf("NA\n");
		k=0;
	}
	return 0;
}

Measured memory_bytes: 1076
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 55
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
int p[MAX_N];

int main(void)
{
  cin >> N;
  REP(i, N) cin >> p[i];

  int cnt = 0;

  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j >= i + 1; j--) {
      if (p[i] > p[j]) {
        swap(p[i], p[j]), cnt++;
        break;
      }
    }
  }
  // for (int i = 0; i < N; i++) cout << p[i] << SLN(i, N);
  if (cnt <= 1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

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

   int a, b;
   cin >> a >> b;

   if (a <= b)
      cout << a << '\n';
   else
      cout << a - 1 << '\n';
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=305;

int n;
int a[N][N],b[N][N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) 
		for (int j=1;j<=n;j++) scanf("%d",&a[i][j]),b[i][j]=(i==j)?0:1e9+1;
	
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++) 
		{
			bool o=false;
			for (int l=1;l<=n;l++)
			if (l!=i&&l!=j) 
			{
				if (a[i][l]+a[l][j]<a[i][j]) {puts("-1");return 0;}
				if (a[i][l]+a[l][j]==a[i][j]) {o=true;break;}
			}
			if (!o) b[i][j]=b[j][i]=a[i][j];
		}
	long long ans=0;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++) if (b[i][j]!=1e9+1) ans+=b[i][j];
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++) b[i][j]=min(b[i][j],b[i][k]+b[k][j]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) if (b[i][j]!=a[i][j]) {puts("-1");return 0;}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

void print_rec(int h, int w){
	for(int i = 0; i < h; i++){
		if(i == 0 || i == (h-1)){
			for(int j = 0; j < w; j++){
				cout << "#";
			}
			cout << endl;
		}
		else{
			for(int j = 0; j < w; j++){
				if(j == 0 || j == (w-1)) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
	}
	cout << endl;
}

int main(void){

	int h,w;
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0) break;
		print_rec(h, w);
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int N;
int ans;
vector<vector<int>> adj;

int Depth(int p, int r) {
  int m1 = 0, m2 = 0;
  for (int a : adj[p]) {
    if (a != r) {
      int x = Depth(a, p);
      if (x > m1) {
	m2 = m1;
	m1 = x;
      } else if (x > m2) {
	m2 = x;
      }
    }
  }
  if (m2 > 0) {
    ans = max(ans, m1+m2+1);
  }
  return m1+1;
}

int main() {
  while (cin >> N) {
    ans = 0;
    adj = vector<vector<int>>(N, vector<int>());
    for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    ans = max(ans, Depth(0, -1));
    cout << (ans%3!=2 ? "First" : "Second") << endl;
  }
}


Measured memory_bytes: 23168
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define f(x,y,z) for(x=y;x<z;x++)
#define pb push_back
#define mp make_pair
#define ld long double
#define fb(x,y,z) for(x=y;x>z;x--)
#define pqf priority_queue <int,vector <int>> 
#define pqb priority_queue <int,vector <int>,greater<int>> 
#define ps(x,y) fixed << setprecision(y) << x
#define PI 3.1415926535
#define mod 1000000007 
#define mods 998244353 
#define setbits(x) __builtin_popcountll(x)
#define all(x) (x).begin(), (x).end()
#define fill(a) memset(a,0,sizeof(a))



// AUTHOR ALOK KUMAR
int lcm(int a,int b)
{
    return (a*b)/(__gcd(a,b));
}
int power(int a,int b)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b/=2;
    }
    return c;
}
void solve()
{
  int n;
  cin>>n;
  if(n%1000==0)
    cout<<"0\n";
  else
  {
    cout<<1000-n%1000<<"\n";
    
  }

    
    
    
}



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































Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N == 0){
			System.out.println(0);
		}
		else if(N == 1 || N == 2){
			System.out.println(1);
		}
		
		else{
			long[] A = new long[N];
			for(int i = 0; i < N; i++){
				A[i] = sc.nextLong();
			}
			int flag = 0;
			int count = 0;
			
			for(int i = 1; i < N; i++){
				if(A[i] != A[i - 1]){
					if(flag == 0){
						flag = A[i] < A[i - 1] ? -1 : 1;
					}
					else if(flag == -1){
						if(A[i] > A[i - 1]){
							flag = 0;
							count++;
						}
					}
					else{
						if(A[i] < A[i - 1]){
							flag = 0;
							count++;
						}
					}
				}
			}
			
			count ++;
			System.out.println(count);
		}
		sc.close();
	}
}


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

int main() {
  int FB[45];
  FB[0] = FB[1] = 1;
  int n;
  cin >> n;
  if (n>1) {
    for (int i=2; i<=n; i++) {
      FB[i] = FB[i-1] + FB[i-2];
    }
  }
  cout << FB[n] << endl;
}



Measured memory_bytes: 3104
K, A, B = map(int, input().split())
count = 0
if(A >= B-2):
    # print(K+1)
    count = K+1
else:
    K = K - (A - 1)

    if(K%2==0):
        count += ((K//2)-1)*(B-A) + B
    else:
        count+=(K//2-1)*(B-A) + B
        count+=1
        # print("No")

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int count0 = 0;
	int count1 = 0;
	for (int j = 0; j < s.size();j++) {
		if (s[j]=='0') {
			count0++;
			
		}
		else {
			count1++;
		}
		
	}
	cout << 2*min(count0,count1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>

using namespace std;

int main() {
  int N;
  cin>>N;
  long long int state[101][64],ans=0;
  for(int i=0;i<101;i++){
    for(int j=0;j<64;j++){
      state[i][j]=0;
    }
  }
  for(int i=0;i<64;i++){
    state[3][i]=1LL;
  }
  state[3][16*0+4*2+1]=0LL;
  state[3][16*0+4*1+2]=0LL;
  state[3][16*2+4*0+1]=0LL;
  for(int i=3;i<100;i++){
    for(int j=0;j<64;j++){
      for(int k=0;k<4;k++){
        if(
          (j*4+k)!=6 &&
          (j*4+k)!=70 &&
          (j*4+k)!=134 &&
          (j*4+k)!=198 &&
          (j*4+k)!=9 &&
          (j*4+k)!=73 &&
          (j*4+k)!=137 &&
          (j*4+k)!=201 &&          
          (j*4+k)!=33 &&
          (j*4+k)!=97 &&
          (j*4+k)!=161 &&
          (j*4+k)!=225 &&
          (j*4+k)!=9 &&
          (j*4+k)!=25 &&
          (j*4+k)!=41 &&
          (j*4+k)!=57 &&
          (j*4+k)!=33 &&
          (j*4+k)!=37 &&
          (j*4+k)!=41 &&
          (j*4+k)!=45 &&
          (j*4+k)!=36 &&
          (j*4+k)!=37 &&
          (j*4+k)!=38 &&
          (j*4+k)!=39 &&
          (j*4+k)!=24 &&
          (j*4+k)!=25 &&
          (j*4+k)!=26 &&
          (j*4+k)!=27 &&
          (j*4+k)!=132 &&
          (j*4+k)!=133 &&
          (j*4+k)!=134 &&
          (j*4+k)!=135
        ){
          state[i+1][(j*4+k)%64]+=state[i][j]%1000000007;
          state[i+1][(j*4+k)%64]%=1000000007;
        }
      }
    }
  }
  for(int i=0;i<64;i++){
    ans+=state[N][i]%=1000000007;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    int dec=0;
    dec=max(max(a,b),c);
    if(a==dec){ans=a*10+b+c;}
    if(b==dec){ans=b*10+a+c;}
    if(c==dec){ans=c*10+b+a;}
    cout<<ans<<endl;
    return 0;
}

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

int main (){

int N, M;
cin >> N >> M;
int gate[M*2+10];
for(int i=0; i<M*2; ++i) cin >> gate[i];
int s=gate[0], e=gate[1];

for(int j=2; j<M*2; j=j+2){

if(s<gate[j]) s = gate[j];
if(e>gate[j+1]) e = gate[j+1];

if(s>e && s==e){
    break;
    }
}

if(e-s+1 <= 0) cout << "0" << endl;
else cout << e-s+1 << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>

long long int power(long long int a, long long int n){
	if(n == 0){
		return 1;
	}
	else if(n % 2 == 0){
		return power(a * a, n / 2);
	}
	else{
		return a * power(a, n - 1);
	}
}

int main(){
	long long int N, K;
	scanf("%lld%lld", &N, &K);
	printf("%lld\n", K * power(K - 1, N - 1));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105;

int n, m;
char c[MAXN][MAXN];
int dp[MAXN][MAXN];

int main() { 

  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &c[i][j]);
    }
    scanf("\n");
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i][j] = n * m;
    }
  }

  if (c[0][0] == '.') {
    dp[0][0] = 0;
  } else {
    dp[0][0] = 1;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + 1 < n) {
        if (c[i][j] == '.' && c[i + 1][j] == '#') {
          dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
        } else {
          dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
      }
      if (j + 1 < m) {
        if (c[i][j] == '.' && c[i][j + 1] == '#') {
          dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
        } else {
          dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
        }
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
long long tot1,tot2,a[200010],b[200010],c[200010],kk;
long long check1(long long ys){
	long long ans=0;
	for(long long i=1;i<=tot1;i++){
		long long k=1,s=tot2+1;
		while(k){
			if(s-k>0&&b[i]*c[s-k]<ys)s-=k,k=k*2;
			else k=k/2;
		}
		ans+=tot2-s+1;
	}
	return ans;
}
long long calc1(){
	long long l=-2e18,r=-1,aa=0;
	while(l<=r){
		long long mid=(l+r)/2,x=check1(mid),y=check1(mid+1);
		if(x<kk&&kk<=y)return mid;
		else if(x<kk)l=mid+1;
		else r=mid-1;
	}
}
long long check2(long long ys){
	long long ans=0;
	for(long long i=1;i<=tot1;i++){
		long long k=1,s=i;
		while(k){
			if(s+k<=tot1&&b[i]*b[s+k]<ys)s+=k,k=k*2;
			else k=k/2;
		}
		ans+=s-i;
	}
	for(long long i=1;i<=tot2;i++){
		long long k=1,s=i;
		while(k){
			if(s+k<=tot2&&c[i]*c[s+k]<ys)s+=k,k=k*2;
			else k=k/2;
		}
		ans+=s-i;
	}
	return ans;
}
long long calc2(){
	long long l=1,r=2e18,aa=0;
	while(l<=r){
		long long mid=(l+r)/2,x=check2(mid),y=check2(mid+1);
		if(x<kk&&kk<=y)return mid;
		else if(x<kk)l=mid+1;
		else r=mid-1;
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	long long n,ans1,ans2,ans3,s1=0,s2=0,s3=0;
	cin>>n>>kk;
	for(long long i=1;i<=n;i++)
	cin>>a[i];
	for(long long i=1;i<=n;i++)
	if(a[i]==0)s1++;
	else if(a[i]<0)s2++,b[++tot1]=a[i];
	else s3++,c[++tot2]=a[i];
	ans1=s2*s3;
	ans2=s1*(n-s1)+s1*(s1-1)/2;
	ans3=s2*(s2-1)/2+s3*(s3-1)/2;
	sort(b+1,b+tot1+1);
	sort(c+1,c+tot2+1);
	reverse(b+1,b+tot1+1);
	if(ans1<kk&&kk<=ans1+ans2){
		cout<<0<<"\n";
		return 0;
	}
	else if(kk<=ans1){
		long long ans=calc1();
		cout<<ans<<"\n";
		return 0;
	}
	else if(kk>ans1+ans2){
		kk=kk-ans1-ans2;
		long long ans=calc2();
		cout<<ans<<"\n";
		return 0;
	}
	return 0;
}


Measured memory_bytes: 4096
import numpy as np
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]
ans = 0
l = np.array(l)
for rep in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if l[i][j] > l[i][k]+l[k][j]:
                    l[i][j] = l[i][k]+l[k][j]
num = [i[1] for i in l] + [0]
for i in a:
    for j in i:
        ans += num[j]
print(ans)


Measured memory_bytes: 12756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		boolean flag[][] = new boolean[n][2];
		int tempA = 0;
		int tempB = 0;
		for (int i = 0; i < m; i++) {
			tempA = scan.nextInt();
			tempB = scan.nextInt();
			if (tempA == 1) {
				flag[tempB - 1][0] = true;
			}
			if (tempB == n) {
				flag[tempA - 1][1] = true;
			}

		}
		for (int i = 0; i < n; i++) {
			if (flag[i][0] && flag[i][1]) {
				System.out.println("POSSIBLE");
				return;
			}
		}

		System.out.println("IMPOSSIBLE");

	}

}

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

const int N = 2e3;
const int mod = 1e9+7;
int dp[N+100][N+100];
int s[N+10],t[N+10];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=n;i++)cin >> s[i];
	for(int i=1;i<=m;i++)cin >> t[i];
	int ans = 1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j] = ((dp[i-1][j]+dp[i][j-1])%mod-dp[i-1][j-1]+mod)%mod;
			if(s[i]==t[j]){
				ans = (ans+dp[i-1][j-1]+1)%mod;
				dp[i][j] = (dp[i][j]+dp[i-1][j-1]+1)%mod;
			}
		}
	}
	cout << ans << "\n";
}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

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

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

int N, Z, W;
int a[2010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> Z >> W;
  REP(i, N) cin >> a[i];
  if (N == 1) cout << abs(a[0]-W) << endl;
  else cout << max(abs(a[N-1]-W), abs(a[N-2]-a[N-1])) << endl;

  return 0;
}

Measured memory_bytes: 256
while line = gets
  value = line.chomp
  week = value.to_i
  money = 100000
  week.times do |i|
    money += (money/100*5)
    uptovalue = money % 1000
    if uptovalue != 0
      money -= uptovalue
      money += 1000
    end
  end
  print money.to_s + "\n"
end



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

int main(){
    long double pi = M_PI;
    long double  a,b,h,m;
    cin >> a >> b >> h >> m;
    long double min;
    min = h*60 + m;
    long double angle;
    angle = abs((1.0/30.0)*m - (1.0/360.0)*min) * pi;
    long double c;
    c = a*a + b*b - 2*a*b*cos(angle);
    c = pow(c,0.5);
    cout << setprecision(20) << c << endl;
}

Measured memory_bytes: 4156
import java.util.*;

public class Main {

	public static boolean bfs (int sx,int sy, int[] spx, int[] spy) {

		int size = 10, spCnt = 0;
		int[] dx = {-1,0,1,-1,0,1,-2,-2,-2,2,2,2};
		int[] dy = {-2,-2,-2,2,2,2,-1,0,1,-1,0,1};
		int[] dx2 = {0,0,1,1,1,0,-1,-1,-1};
		int[] dy2 = {0,-1,-1,0,1,1,1,0,-1,-1};
		boolean[][] park = new boolean[size][size];

		Queue<Integer> queueX = new LinkedList<Integer>();
		Queue<Integer> queueY = new LinkedList<Integer>();

		queueX.add(sx);
		queueY.add(sy);

		while (!queueX.isEmpty()) {

			if (spCnt == spx.length) {
				return true;
			}

			for (int i = 0; i < dx2.length; i++) {
				int y = spy[spCnt] + dy2[i];
				int x = spx[spCnt] + dx2[i];
				if (0 <= y && y < size &&
					0 <= x && x < size) {
					park[y][x] = true;
				}

			}

			Queue<Integer> nx = new LinkedList<Integer>();
			Queue<Integer> ny = new LinkedList<Integer>();

			while (!queueX.isEmpty()) {
				int x = queueX.poll();
				int y = queueY.poll();
				for (int i = 0; i < dx.length; i++) {
					int nextX = x + dx[i];
					int nextY = y + dy[i];
					if (0 <= nextX && nextX < 10 &&
						0 <= nextY && nextY < 10 &&
						park[nextY][nextX]) {
						nx.add(nextX);
						ny.add(nextY);
					}
				}
			}
			spCnt++;
			park = new boolean[size][size];
			queueX = nx;
			queueY = ny;
		}

		return false;
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int sx = sc.nextInt();
			int sy = sc.nextInt();
			if (sx == 0 && sy == 0) break;
			sc.nextLine();
			int n = sc.nextInt();
			int[] spx = new int[n];
			int[] spy = new int[n];
			sc.nextLine();
			for (int i = 0; i < n; i++) {
				spx[i] = sc.nextInt();
				spy[i] = sc.nextInt();
			}
			sc.nextLine();
			System.out.println(bfs(sx,sy,spx,spy) ? "OK" : "NA");

		}

	}

}

Measured memory_bytes: 11000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CGreenBin {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      unordered_map<string, int> mp;
      rep(i, n) {
        string s; cin >> s;
        sort(all(s));
        mp[s]++;
      }
      ll ans = 0;
      for(auto e: mp) {
        ll c = e.second;
        ans += c*(c-1)/2;
      }
      cout << ans << endl;
    }
};

signed main() {
  CGreenBin solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,dp[305][305][305],vis[305][305];
string st;
void dfs(int l,int r)
{
	if (l>r) return;
	if (vis[l][r]) return;
	vis[l][r]=1;
	if (l==r)
	{
		fill(dp[l][r],dp[l][r]+m+1,1);
		return;
	}
	int i;
	dfs(l+1,r-1);
	dfs(l+1,r);
	dfs(l,r-1);
	for (i=0;i<=m;i++)
	{
		dp[l][r][i]=0;
		if (st[l]==st[r]) dp[l][r][i]=max(dp[l][r][i],dp[l+1][r-1][i]+2);
		else
		{
			if (i) dp[l][r][i]=max(dp[l][r][i],dp[l+1][r-1][i-1]+2);
			dp[l][r][i]=max(dp[l][r][i],dp[l+1][r][i]);
			dp[l][r][i]=max(dp[l][r][i],dp[l][r-1][i]);
		}
	}
}
int main()
{
	cin>>st>>m;
	st=" "+st;
	dfs(1,st.size()-1);
	cout<<dp[1][st.size()-1][m]<<endl;
	return 0;
}

Measured memory_bytes: 110464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int H, W;
	cin >> H >> W;

	int C[10][10];
	rep(i, 10) {
		rep(ii, 10) {
			cin >> C[i][ii];
		}
	}
	
	int T[10] = {};
	rep(i, 10) {
		int saishou = C[i][1];

		rep1(j, 8) {
			int kaisuu = 1;
			rep(iii, j) kaisuu *= 8 - iii;

			rep(k, kaisuu) {
				int ikisaki[10] = {};
				ikisaki[0] = i;
				ikisaki[j + 1] = 1;
				int tukatta[10] = {};
				tukatta[i] = 1;
				tukatta[1] = 1;

				int karik = k;
				rep1(l, j) {
					int kariikisaki = karik % (9 - l);
					rep(m, kariikisaki + 1) {
						if (tukatta[m]) {
							kariikisaki++;
						}
					}
					ikisaki[l] = kariikisaki;
					tukatta[kariikisaki] = 1;
					karik /= (9 - l);
				}

				int goukei = 0;
				rep(l, j + 1) {
					goukei += C[ikisaki[l]][ikisaki[l + 1]];
				}
				saishou = min(saishou, goukei);
			}



		}
		T[i] = saishou;
	}

	int kotae = 0;
	int A;
	rep1(i, H) {
		rep1(ii, W) {
			cin >> A;
			if (A != -1) kotae += T[A];
		}
	}
	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int,input().split())

def calculate(a, b, h, m):
    hradians = ((h % 12) / 12)*360 + (((m/60) % 12) / 12)*360
    mradians = (m / 60) * 360

    hx = a * math.sin(math.radians(hradians))
    hy = a * math.cos(math.radians(hradians))

    mx = b * math.sin(math.radians(mradians))
    my = b * math.cos(math.radians(mradians))

    print(distance(hx,hy,mx,my))

def distance(x1,y1,x2,y2):
    return math.sqrt(abs(x1-x2)**2 + abs(y1-y2)**2)
calculate(A, B, H, M)

Measured memory_bytes: 9608
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 1e6+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main()
{

    ll a,b,n,ans,i;
    cin>>a>>b>>n;
    if(b<=n){
    	i=b-1;
	}else{
		i=n;
	}
	ans=floor(a*i/b)-a*floor(i/b);
   cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3592