akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int h,w,n;
   cin>>h>>w>>n;
   int ny,nx;
   cin>>ny>>nx;
   string s,t;
   cin>>s>>t;
   int l=0,r=w+1;
   if(s[n-1]=='L')l++;
   if(s[n-1]=='R')r--;
   bool able=true;
   for(int i=n-2;i>=0;i--){
       if(t[i]=='L'&&r<=w)r++;
       if(t[i]=='R'&&l>0)l--;
       if(s[i]=='L')l++;
       if(s[i]=='R')r--;
       if(abs(l-r)<=1)able=false;
   }
   if(l>=nx||nx>=r)able=false;
   int u=0,d=h+1;
   if(s[n-1]=='U')u++;
   if(s[n-1]=='D')d--;
   for(int i=n-2;i>=0;i--){
       if(t[i]=='U'&&d<=h)d++;
       if(t[i]=='D'&&u>0)u--;
       if(s[i]=='U')u++;
       if(s[i]=='D')d--;
       if(abs(u-d)<=1)able=false;
   }
   if(u>=ny||ny>=d)able=false;
   if(able)cout<<"YES"<<"\n";
   else cout<<"NO"<<"\n";
}


Measured memory_bytes: 920
def inpl(): return [int(i) for i in input().split()]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x],dist[x] = find(par[x]),dist[x]+dist[par[x]]
        return par[x]
N, M = inpl()
par = list(range(N+1))
dist = [0 for _ in range(N+1)]

for _ in range(M):
    l, r, d = inpl()
    fl = find(l)
    fr = find(r)
    if fl == fr and d + dist[l] - dist[r] != 0:
        print('No')
        break
    else: 
        par[fr] = fl
        dist[fr] = d + dist[l] - dist[r]
else:
    print('Yes')


Measured memory_bytes: 9124
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 入力文字列の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[][] s = new char[N][];
			IntStream.range(0, N).forEach(i -> s[i] = scanner.next().toCharArray());
			boolean result = true;
			for (int i = 1; i < N; i++) {
				// 直前の文字列の最後の文字と現在の文字列の最初の文字と比較
				if (s[i - 1][s[i - 1].length - 1] != s[i][0]) {
					result = false;
					break;
				}
			}
			System.out.println(result ? "YES" : "NO");
		}
	}
}


Measured memory_bytes: 35888
n = gets.chomp!.to_i
vs = gets.chomp!.split(" ")
vs = vs.map{|item| item = item.to_i}
cs = gets.chomp!.split(" ")
cs = cs.map{|item| item = item.to_i}
vcs = []

for i in 0..n-1
	vcs = vcs + [Complex(vs[i],cs[i])]
end

ans = -Float::INFINITY

for kosu in 0..n
	vcs.combination(kosu){|arr| 
		alans = 0
		for j in 0..arr.length-1
			alans = alans + arr[j].real - arr[j].imag
		end
		
		if ans <= alans && alans >= 0 then
		ans = alans
		end
	}
end

puts ans

Measured memory_bytes: 4216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        var k = Integer.parseInt(scaner.nextLine());
        var a_b = scaner.nextLine().split(" ");
        var a = Integer.parseInt(a_b[0]);
        var b = Integer.parseInt(a_b[1]);
        
        int i = 1;
        boolean isOK = false;
        for(;i*k<=b; i++) {
            var r = k*i;
            if(a <= r && r <= b) {
                System.out.println("OK");
                isOK = true;
                break;
            } 
        }

        if (!isOK) {
            System.out.println("NG");
        }

        scaner.close();

    }
}


Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}


int main(){
	ios_base::sync_with_stdio(false);
	cout << setprecision(12);
    string s,t;
    cin >> s >> t;
    vector< vector<int> > pos;
    pos.resize(26);
    for(int i=0;i<s.length();i++){
        pos[s[i]-'a'].pb(i+1);
    }
    for(int i=0;i<t.length();i++){
        if(pos[t[i]-'a'].size()==0){
            cout << "-1" << endl;
            return 0;
        }
    }
    ll ans = 0;
    ll last = -1;
    ll count = 0;
    for(int i=0;i<t.length();i++){
        int ind = t[i]-'a';
        if(last>=pos[ind][pos[ind].size()-1]){
            last = pos[ind][0];
            count++;
        }
        else {
            auto it = upper_bound(pos[ind].begin(),pos[ind].end(),last);
            int j = it-pos[ind].begin();
            last = pos[ind][j];
        }
        ans = count*(s.length())+last;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1228
use std::io;

fn read_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .ok();
  line
}

fn main() {
  let line = read_line();

  let mut v: Vec<i32> = line.trim()
    .split_whitespace()
    .map(|val| { val.parse().unwrap() })
    .collect();
  
  v.sort();
  println!("{} {} {}", v[0], v[1], v[2]);
}



Measured memory_bytes: 5028
rooms = [0] * (4*3*10)
count = int(input())
for i in range(count):
    b, f, r, v = [int(x) for x in input().split()]
    rooms[30*(b-1) + 10*(f-1) + (r-1)] += v
  
for i, room in enumerate(rooms, start=1):
    print('', room, end='')
    if i%10 == 0:
        print()
    if i%30 == 0 and i%120 != 0:
        print('#'*20)

Measured memory_bytes: 7664
def main():
    n = input()
    hh = map(int, raw_input().split())
    for i in xrange(n - 1, 0, -1):
        if hh[i - 1] <= hh[i]:
            continue
        elif hh[i - 1] - 1 == hh[i]:
            hh[i - 1] -= 1
        else:
            print 'No'
            return
    print "Yes"


if __name__ == '__main__':
    main()


Measured memory_bytes: 11340
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0];
    long a = tmp[1], b = tmp[2], c = tmp[3], d = tmp[4];
    string s = rdStr;

    bool ok = !s[a..max(c, d)].canFind("##");
    if (c > d) ok &= s[b-2..d+1].canFind("...");

    writeln(ok ? "Yes" : "No");
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n,x,t;
   cin>>n>>x>>t;
   
   ll ans = (n+x-1)/x;
   ans*=t;
   cout<<ans;
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);

		String S = fs.nextLine();

		int len = S.length();
		long ans = 0;

		for (int i = 0; i < Math.pow(2, len - 1); i++) {
			int start = 0;
			for (int j = 0; j < len -1; j++) {
				if ((i & (1<<j)) == (1<<j)) {
					if (start == j) {
						ans +=  Character.getNumericValue(S.charAt(start));
						start++;
					} else {
						ans += Long.parseLong(S.substring(start, j + 1));
						start = j + 1;
					}

				}
			}
			ans += Long.parseLong(S.substring(start));
		}

		System.out.println(ans);

	}

	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

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

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

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

	}


}


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

#define LL long long
#define COIN const int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

bool a[3][3]={{0,0,0},{0,0,0},{0,0,0}},yes=0;
int ok[3][3],n,b[10],i,j,k;
COIN g=3;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	REP(i,g)
		REP(j,g)
			cin >>ok[i][j];
	cin >>n;
	REP(i,n)
		cin >>b[i];
	REP(i,g)
	{
		REP(j,g)
		{
			REP(k,n)
			{
				if (ok[i][j]==b[k]) a[i][j]=1;
			}
		}
	}
	REP(i,g)
	{
		REP(j,g)
		{
			if(a[i][j]==0)
			{
				yes=1;
				break;
			}
		}
		if (yes==0)
		{
			cout <<"Yes"<<endl;
			return 0;
		}
		REP(j,g)
		{
			if(a[j][i]==0)
			{
				yes=0;
				break;
			}
		}
		if (yes==1)
		{
			cout <<"Yes"<<endl;
			return 0;
		}
	}
	REP(i,g)
	{
		if (a[i][i]==0)
		{
			yes=1;
			break;
		}
	}
	if (yes==0)
	{
		cout <<"Yes"<<endl;
		return 0;
	}
	REP(i,g)
	{
		if (a[2-i][i]==0)
		{
			yes=0;
			break;
		}
	}
	if (yes==1)
	{
		cout <<"Yes"<<endl;
		return 0;
	}
	cout <<"No"<<endl;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
def solve():
    r, d, x2000 = list(map(int, input().split()))
    x2001_2010 = []
    now = x2000
    for i in range(1, 11):
        now = now * r - d
        x2001_2010.append(now)
    return "\n".join([str(i) for i in x2001_2010])


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

int main(){
    int n, a;
    cin >> n;
    double tmp = 0;
    rep(i, n){
        cin >> a;
        tmp += (1/(double)a);
    }
    
    std::cout << std::fixed<<std::setprecision(10) << 1/tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if ((a*100+b*10+c)%4==0)
{
    cout<<"YES"<<endl;
}
else
{
    cout<<"NO"<<endl;
}

    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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int N;
cin >> N;
map<ll ,ll> mp,dame;
vl A(N);
rep(i,N) {
    cin >> A[i];
    mp[ A[i] ]++;
}

ll ans = 0;
for(auto x: mp) {
    ll cnt = x.second*(x.second - 1)/2;
    ans += cnt;
    dame[x.first] = cnt - (x.second - 1)*(x.second -2)/2;
}

rep(i,N) {
    cout << ans - dame[A[i]] << endl;
}

return 0;
}

Measured memory_bytes: 18944
#include <stdio.h>
int main(void)
{
  int x;
  scanf("%d",&x);
  x %= 100;
  x %= 10;
  
  if(x==2 || x==4 || x==5 || x==7 || x==9)
    printf("hon\n");
  else if(x==0 || x==1 || x==6 || x==8)
    printf("pon\n");
  else if(x==3)
    printf("bon\n");
  
  return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define forn(i,n)    for (int i = 0; i < n; i++)
#define fork(i,k,n)  for (int i = k; i <= n; i++)
#define forkr(i,k,n) for (int i = k; i >= n; i--)


 int main()
{
ll n;
while(cin>>n){
ll c=0;
for(int i=0;i<10;i++){
 for(int j=0;j<10;j++){
  for(int k=0;k<10;k++){
    for(int l=0;l<10;l++){
       if(i+j+k+l==n){
        c++;
       }
    }
  }
 }
}
cout<<c<<endl;
c=0;
}
}







Measured memory_bytes: 2980
S = input()
S = S[::-1]
# print(S)
# print(len(S))


# t_sub = ["dreamer", "dream", "eraser", "erase"]
t_sub = ["remaerd", "maerd", "resare", "esare"]

def func():
    i = 0
    while True:
        flag = False
        for t in t_sub:
            ret = (S.find(t, i) == i)
            # print(S,".find(",t,", ",i,") == ",i, "ret=", ret)
            if ret ==True:
                if (i+len(t) == len(S)):
                    return "YES"
                else:
                    i += len(t)
                    flag = True
                    break
        if flag != True:
            return "NO"

print(func())


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

int main() {
  int a,b,c;
  cin>> a >> b >> c;
 
  if(a+b==c||b+c==a||c+a==b){
    cout<<"Yes"<<endl;
  }
 
  else{
    cout<<"No"<<endl;
  }
    

}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> que;
  REP(i, n) {
    int a;
    cin >> a;
    que.push(a);
  }
  REP(i, m) {
    int t = que.top();
    que.pop();
    t /= 2;
    que.push(t);
  }
  ll ans = 0;
  while (que.size()) {
    int t = que.top();
    que.pop();
    ans += t;
  }
  cout << ans << endl;
  return 0;
}

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

float fourfive(float f);

int main(void){
    float a,b,c,d,e,f;
    float aa,bb,cc,dd,ee,ff;
    float x,y;
    float tmp1,tmp2;
    int xx, yy;

    while(1){
        a = 2000;
        scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f);
        if(a == 2000)break;

        tmp1 = c*e - b*f;
        tmp2 = a*e - b*d;
        x = tmp1 / tmp2;
        tmp1 = a*f - c*d;
        tmp2 = a*e - b*d;
        y = tmp1 / tmp2;
        
        x = fourfive(x);
        y = fourfive(y);

        printf("%.3f %.3f\n", x, y);
        
    }

    return 0;
}

float fourfive(float f){

    int ff;

    if(f > 0.0){
        f *= 1000.0;
        f += 0.5;
        ff = (int)f;
        f = (float)ff / 1000.0;
    }
    else {
        f *= -1000.0;
        f += 0.5;
        ff = (int)f;
        f = (float)(-1 * ff) / 1000.0;
    }

    return f;
}

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

int main(){ 
    int n,ans=1000; cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        int d=0;
        while(a%2==0){
            a=a/2;
            d++;
            }
        ans=min(ans,d);
    }
    cout<<ans<<endl;
    return 0;
    }


Measured memory_bytes: 256
fn main() {
    let (n, m, v) = read();
    let ans = solve(v);
    write(ans);
}

#[derive(Debug)]
pub struct Tendodai {
    height: i32,
    rinsetsu: Vec<i32>,
}

fn read() -> (i32, i32, Vec<Tendodai>) {
    let mut l1 = String::new();
    std::io::stdin().read_line(&mut l1).ok();
    let mut iter = l1.trim().split_whitespace();
    let n = iter.next().unwrap().parse::<i32>().unwrap();
    let m = iter.next().unwrap().parse::<i32>().unwrap();

    let mut l2 = String::new();
    std::io::stdin().read_line(&mut l2).ok();
    let iter = l2.trim().split_whitespace();
    let mut v = Vec::<Tendodai>::new();
    for (i, h) in iter.enumerate() {
        let h = h.trim().parse::<i32>().unwrap();
        v.push(Tendodai{height: h, rinsetsu: Vec::<i32>::new(),});
    }

    for i in 0..m {
        let mut l1 = String::new();
        std::io::stdin().read_line(&mut l1).ok();
        let mut iter = l1.trim().split_whitespace();
        let a = iter.next().unwrap().parse::<i32>().unwrap();
        let b = iter.next().unwrap().parse::<i32>().unwrap();

        v[a as usize - 1].rinsetsu.push(b - 1);
        v[b as usize - 1].rinsetsu.push(a - 1);
    }

    (n, m, v)
}
 
fn write(x: i32) {
    println!("{}", x);
}
 
fn solve(v: Vec<Tendodai>) -> i32 {
    let mut count = 0; 
    for i in v.iter() {
        if i.rinsetsu.len() == 0 {
            count += 1;
        } else {
            if i.rinsetsu.iter().all(|&x| i.height > v[x as usize].height) {
                count += 1;
            }
        }
    }

    count
}

Measured memory_bytes: 8868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int k;
  cin>>k;
  ll sum = 0;
  for(int i = 1; i<=k; i++){
    for(int j = 1; j<=k; j++){
      for(int l = 1; l<=k; l++){
        sum+=__gcd(i,__gcd(j,l));
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3568
#
# 1149: Cut the Cakes
#

loop do
    n, w, h = gets.split.map(&:to_i)
    break if (n | w | h) == 0
    
    cakes = [[w, h]]
    
    n.times do
        pi, si = gets.split.map(&:to_i)
        pi -= 1
        
        wi, hi = cakes[pi]
        cakes.delete_at(pi)
        
        si %= wi + hi
        if si < wi 
            wi0 = si 
            wi1 = wi - wi0
            if wi0 < wi1
                cakes += [[wi0, hi], [wi1, hi]]
            else
                cakes += [[wi1, hi], [wi0, hi]]
            end
        else
            hi0 = hi - (si - wi)
            hi1 = hi - hi0
            if hi0 < hi1
                cakes += [[wi, hi0], [wi, hi1]]
            else
                cakes += [[wi, hi1], [wi, hi0]]
            end
        end
    end
    
    puts cakes.map{|wi, hi| wi * hi}.sort.join(' ')
end
    

Measured memory_bytes: 6156
#include<iostream>
#include<cstdio>
#define N 123456
#define ll long long 
using namespace std;
ll n,a[N],ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
	{
		ans+=a[i]/2,a[i]%=2;
		if(i<n&&a[i]&&a[i+1])
			ans++,a[i]--,a[i+1]--;
	}
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
int x, y, z;
int a, b, c;
cin >> x >> y >> z;
a = x;
b = y;
c = z;
if (a = x) {
  a = y;
  b = x;
}
if (a = y) {
  a = z;
  c = y;
}
cout << a << endl;
cout << b << endl;
cout << c << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
vector<int> G[200010];
long long mod = 1000000007;
const int MX = 200010;
ll f[MX],inv[MX],fi[MX];
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    }
   f[0] = 1; f[1] = 1; fi[0] = 1;fi[1] = 1;
    for(int i=2;i<MX;i++){
        f[i] = f[i-1]*i%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}
ll ans[200010],dp[200010],sz[200010];
ll dfs(int s,int p){
    ll ret = 1,val = 1;
    for(int v:G[s]){
        if(v==p) continue;
        ll x = dfs(v,s);
        (val *= dp[v]) %= mod;
        (val *= fi[x]) %= mod;
        ret += x;
    }
    (val *= f[ret - 1]) %= mod;
    dp[s] = val;
    sz[s] = ret;
    return ret;
}
ll pw(ll a, ll x){
    ll ret = 1;
    while(x){
        while(!(x&1)){
            (a *= a) %= mod;
            x /= 2;
        }
        (ret *= a) %= mod;
        x--;
    }
    return ret;
}
ll inverse(ll x){
    return pw(x,mod - 2);
}

int n;
void dfs1(int s,int p){
    ans[s] = dp[s];
    int i;
    for(int v:G[s]){
        if(v==p) continue;
        ll x = dp[v],y = dp[s],s1 = sz[v],s2 = sz[s];
        sz[v] = n; sz[s] = n - s1;
        (dp[s] *= fi[n - 1]%mod*f[s1]%mod*inverse(x)%mod*f[sz[s] - 1]%mod) %= mod;
        (dp[v] *= f[n - 1]%mod*dp[s]%mod*fi[sz[s]]%mod*fi[s1 - 1]%mod) %= mod;
        dfs1(v,s);
        dp[v] = x; dp[s] = y;
        sz[v] = s1; sz[s] = s2;
    }
}

int main(){
    int i;
    cin >> n;
    for(i=0;i<n - 1;i++){
        int a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    solve();
    dfs(0,-1);
    dfs1(0,-1);
    for(i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}

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

int main()
{
  int a, b, c;
  int d = 0;
  cin >> a >> b >> c;
  for(int i = a; i <= b; i++)
  {
    if(c % i == 0)
    {
      d++;
    }
  }

  cout << d << endl;

  return 0;
}


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

bool isLeap(int y) {
  if(y % 400 == 0) return true;
  if(y % 100 == 0) return false;
  return y % 4 == 0;
}

int main() {
  int a, b;
  bool first = true;
  while(cin >> a >> b && (a|b)) {
    if(first) first = false;
    else cout << endl;
    bool flag = false;
    for(int i = a; i <= b; ++i) {
      if(isLeap(i)) {
        cout << i << endl;
        flag = true;
      }
    }
    if(!flag) cout << "NA" << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	int a, b, c;	cin >> a >> b >> c;
	for (int i = 1; i <= (int)1e7; i++){
		if (a & 1 || b & 1 || c & 1){
			cout << i-1 << "\n";
			return 0;
		}

		int aa = a/2, bb = b/2, cc = c/2;
		a = bb+cc;
		b = cc+aa;
		c = aa+bb;
	}
	cout << "-1\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,i,j,a[200001],num,f[200001],sum;
int main(){
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=n;i>=1;i--){
		num=0;
		for(j=2;i*j<=n;j++){
			if(f[i*j]) num++;
		}
		if(num%2==a[i]) continue;
		else{
			f[i]=1;
			sum++;
		}
	}
	cout<<sum<<endl;
	for(i=1;i<=n;i++) if(f[i]) cout<<i<<" ";
}

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

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	sort(a.begin(), a.end());
	
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s, t;
   cin >> s >> t;
   sort(s.begin(), s.end());
   sort(t.begin(), t.end());

   reverse(t.begin(), t.end());
   if (s < t)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string ans="APPROVED";
int n;
cin>>n;
int x;
for(int i=0;i<n;i++)
{
cin>>x;
if(x%2==0 && (x%3!=0 && x%5!=0))
{
ans="DENIED";
}
}
cout<<ans;
}



/*
 * ||||


 */

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans=0;
    n-=400;
    n/=200;
    ans=8-n;


    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int f(int x){
    return x * x;
}

int main(void){
    int n, a, b, c, tmp;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b >> c;
        if(a > b){
            tmp = a;
            a = b;
            b = tmp;
        }
        if(b > c){
            tmp = b;
            b = c;
            c = tmp;
        }
        if(f(c) == f(a) + f(b))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include<stdio.h>

int main(void){
    int elements[101][101] = {};
    int rows, columns;
    scanf("%d %d", &rows, &columns);
    for(int i=0; i<rows; i++){
        for(int j=0; j<columns; j++){
            scanf("%d", &elements[i][j]);
            elements[i][columns]    += elements[i][j];
            elements[rows][j]       += elements[i][j];
            elements[rows][columns] += elements[i][j];
            printf("%d ", elements[i][j]);
        }
        printf("%d\n", elements[i][columns]);
    }
    for(int i=0; i<columns; i++){
        printf("%d ", elements[rows][i]);
    }
    printf("%d\n", elements[rows][columns]);
    return 0;
}


Measured memory_bytes: 2100
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(li[k - 1])



Measured memory_bytes: 2940
<?php
list($N,$X,$Y)=sscanf(trim(fgets(STDIN)),"%d %d %d");
$nums = array();
for($i=1;$i<$N;$i++){
    //print("[".$i."]\n");
    for($j=$i+1;$j<=$N;$j++){
        $dif = $j-$i;
        if((abs($X-$i)+1+abs($j-$Y)) < $dif){
            $dif = (abs($X-$i)+1+abs($j-$Y));
        }
        if($dif > 0){
            if(!isset($nums[$dif])){
                $nums[$dif] = 1;
            }else{
                $nums[$dif]++;
            }
        }
        //print($dif."   \n");
    }
    //printf("\n");
}
for($i=1;$i<$N;$i++){
    if(!isset($nums[$i])){
        print("0"."\n");
    }else{
        print($nums[$i]."\n");
    }
}



Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u) a--;
  if(t == u) b--;
  cout << a << " " << b << endl;
}

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


int main(){
	int long long n,a,ans=1,unans=1,v,h=0;
	cin>>n;
	bool sea[n+2]={};
	map<int long long, vector<int>> m;
	for(int p=1;p<n+1;p++){
		cin>>a;
		m[a].push_back(p);
		sea[p]=true;
		if(a==0){
			h++;
		}
	}
	if(h==n){
		ans=0;
	}
	//陸はtrue海はfalse
	for(const auto p : m){
		//cout<<"a"<<endl;
		for(int long long v: p.second){
			//cout<<v<<"second"<<endl;
			if(!sea[v-1]&&!sea[v+1]){
				unans--;
			}
			if(sea[v-1]&&sea[v+1]){
				unans++;
			}
			sea[v]=false;
		}
		ans=max(ans,unans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 14160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	ll n, a, b; cin >> n >> a >> b;
	ll cnt = 0;

	if (a == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	else if (b == 0)
	{
		cout << n << endl;
		return 0;
	}

	cnt = (n / (a + b)) * a;
	cnt += min(n % (a + b), a);

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int n;
    cin >> n;
    if (n%2 == 0) {
        cout << (n-2)/2 << "\n";
    } else {
        cout << (n-1)/2 << "\n";
    }
}


Measured memory_bytes: 256
import bisect
n=int(input())
a=[int(i) for i in input().split()]
b=[0]*(10**5)
for i in range(n):
    b[a[i]]+=1
ma=0
for i in range(1,10**5-1):
    ma=max(b[i-1]+b[i]+b[i+1],ma)
print(ma)
#累積和でやると早い


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 111;

string N;
int num[MAX];
int K;

ll dp[MAX][4][2]; // dp[n][k][l] : 上からn桁決めて0以外の桁がk個ある、l=1のときN以下であることが確定している

ll solve() {
    REP (i, N.size()) num[i] = N[i] - '0';

    dp[0][0][1] = 1; // 先頭が0
    dp[0][1][1] = num[0] - 1; // 先頭がN[0]以下
    dp[0][1][0] = 1; // 先頭がN[0]なら不定

    // REP (i, N.size()) dp[i][0][1] = 1; // 先頭が0なら確定

    FOR (i, 1, N.size()) {
        dp[i][0][1] = 1;
        FOR (k, 1, 4) {
            dp[i][k][1] += dp[i-1][k][1]; // 下回ることが確定してて0を追加
            dp[i][k][1] += dp[i-1][k-1][1] * 9; // 下回ることが確定してて1~9を追加
            
            if (num[i] == 0) {
                dp[i][k][0] += dp[i-1][k][0]; // kが増えずに確定もしない
            } else {
                dp[i][k][1] += dp[i-1][k][0]; // 下回ることが確定してなくて0を追加して下回ることが確定
                dp[i][k][1] += dp[i-1][k-1][0] * (num[i]-1); // 下回ることが確定してなくて1以上を追加して下回ることが確定
                dp[i][k][0] += dp[i-1][k-1][0]; // kが増えるが確定しない
            }
        }
    }

    /*
    REP (x, 2) {
        if (x == 1) cout << "decided: " << endl;
        else cout << "undecided: " << endl;
        REP (k, 4) {
            cout << "k = " << k << " : ";
            REP (i, N.size()) {
                cout << dp[i][k][x] << " ";
            }
            cout << endl;
        }
    }
    */

    return dp[N.size()-1][K][0] + dp[N.size()-1][K][1];
}

int main() {
    cin >> N >> K;
    cout << solve() << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,N;
int A[10101];
int X[202][202];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>N;
	FOR(i,N) cin>>A[i];
	
	int cur=0;
	FOR(y,H) {
		FOR(i,W) {
			x=(y%2==0)?i:(W-1-i);
			
			while(A[cur]==0) cur++;
			X[y][x]=cur+1;
			A[cur]--;
		}
		FOR(x,W) _P("%d%c",X[y][x],(x==W-1)?'\n':' ');
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 384
// lcm、__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define ll long long
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    string str;
    cin>>n;
    set<string> a;
    rep(i,n)   {cin >> str;
    a.insert(str);
    
    }
    cout<<a.size()<<endl;

    return 0;
}

Measured memory_bytes: 19276
# 必要な回数を連想配列で対応付ける。
alpha = "bcdefghijklmnopqrstuvwxyza"
last_process = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
need_char_point = {}
need_point_char = {}
pointa = 0
for i in reversed(range(len(alpha))):
    need_char_point[alpha[pointa]] = i
    need_point_char[i] = alpha[pointa]
    pointa += 1

# print(need_point)
s = str(input())
k = int(input())
ans = ""
for i in range(len(s)):
    if k >= need_char_point[s[i]]:
        k -= need_char_point[s[i]]
        ans += "a"
    else:
        ans += s[i]
if k > 0:
    k %= 26
    for i in range(len(last_process)):
        if ans[-1] == last_process[i]:
            tmp = i
            break
    hoge = list(ans)
    hoge[-1] = last_process[tmp+k]
    ans = "".join(hoge)

print(ans)


Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef pair<int, int> P;

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

	vector<int> dist(n, 1e7);
	dist[0] = 0;

	priority_queue<P, vector<P>, greater<P>> q;
	q.push(MP(0, 0));

	while (!q.empty()){
		int d, pos;
		tie(d, pos) = q.top();
		q.pop();

		if (dist[pos] < d) continue;
		if (pos == n-1) break;

		if (p[pos] == 0){
			FOR(i, 1, 7){
				int npos = min(pos + i, n - 1);
				if (dist[npos] <= d + 1) continue;
				dist[npos] = d + 1;
				q.push(MP(d + 1, npos));
			}
		}
		else{
			if (dist[pos + p[pos]] <= d) continue;
			dist[pos + p[pos]] = d;
			q.push(MP(d, pos + p[pos]));
		}
	}

	cout << dist[n - 1] << endl;


	return 0;
}

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

#define int                long long
#define all(v)             v.begin(),v.end()
#define rep(i,a,b)         for(int i=a;i<b;i++)
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(n)              (int)(n.size())
#define min3(a,b,c)        fmin(a,fmin(b,c))
#define max3(a,b,c)        fmax(a,fmax(b,c))
#define IOS                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define hell               1000000007
#define dec(a)             fixed<<setprecision(a)
#define tr(container, it)  for(auto it = container.begin(); it != container.end(); it++)
#define vec                vector

int solve()
{
  int n;
  cin>>n;
  int ans=(n/500)*1000;
  ans=ans+((n%500)/5)*5;
  cout<<ans<<endl;
}

signed main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int tc=1;
  // cin>>tc;
  while(tc--)
  {
    solve();
  }
}

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

xyh = [tuple(map(int, input().split())) for _ in range(N)]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        for i, (x,y,h) in enumerate(xyh):
            if h != 0:
                H = h + abs(x - cx) + abs(y - cy)

        for i, (x,y,h) in enumerate(xyh):
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                flag = False
                break
        if flag:
            print(cx, cy, H)
            exit()


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#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 ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	cout << n*(n+1)/2 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 10000
#define Q 500

int main(){
  int S[N]={0};
  int T[Q]={0};
  int U[5000]={0};
  int i,j,k=0,n,q,count=0,F;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);

  for(i=0;i<n;i++){
    F=0;
    for(j=0;j<q;j++){
      for(k=0;k<count;k++){
	if(S[i]==U[k]) F=1;
      }
      if(S[i]==T[j]&&F==0){
	U[k]=S[i];
	k++;
	count++;
      }
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2076
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()
A = [-I() for i in range(N)]

# Aの最大非増加部分列の長さを求めればOK

from bisect import bisect_left,bisect

def LNDS(l):  #リストlのLNDSの長さを求める
    dp = [float('inf')]*(len(l)+1)
    dp[0] = -float('inf')
    for i in range(len(l)):
        j = bisect(dp,l[i])
        dp[j] = l[i]
    return bisect_left(dp,float('inf'))-1

print(LNDS(A))

Measured memory_bytes: 77456
#include <stdio.h>

int num[1000000];

int main(void)
{
	int n, i, j;
	int count;
	
	for (i = 0; i <= 999999; i++){
		num[i] = 1;
	}
		
	num[0] = 0;
	num[1] = 0;
	
	for (i = 2; i <= 999999; i++){
		if (num[i] == 1){
			for (j = i + i; j <= 999999; j += i){
				num[j] = 0;
			}
		}
	}
	
	while (scanf("%d", &n) != EOF){
		count = 0;
		for (i = 0; i <= n; i++){
			if (num[i] == 1){
				count++;
			}
		}
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 4500
N, W = gets.split.map(&:to_i)

h = Array.new(W+1, 0)
N.times do 
    w, v = gets.split.map(&:to_i)

    (W - w).downto(0) do |i|
        h[w + i] = h[i] + v if h[w + i] < h[i] + v 
    end
end

puts h.max

Measured memory_bytes: 15164
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;
int main(){
    string s;
    cin >> s;
    int counter = 0;
    for (size_t i = 0; i < s.size(); i++)
    {
        if(s[i] == '1') counter++;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
import Text.Printf

log2 k n x =
  if n > x
  then k-1
  else log2 (k+1) (2*n) x

ans x =
  let l2 = log2 0 1 x
  in
    if 2^(l2+1) - 1 == x
    then l2+1
    else l2

main = do
  x <- fmap read getLine :: IO Int
  let o = ans x
  print o
  



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

int c(int a, int b) {
    return ((a - 1) / b) + 1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int L, R, d;
    cin >> L >> R >> d;
    int a = c(L, d);
    int b = R / d;
    cout << b - a + 1 << '\n';


    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3648
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if
#define unint unsigned int
#define sint short int
#define lint long long int
#define Size 100000
#define CoinK 500

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    lint x,y,cmp=0;
    cin>>x>>y;
    cmp=x*CoinK;
    if(cmp>=y){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
}


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

using ll = long long;

using namespace std;
int main()
{
  ll n;
  cin >> n;

  bool res = false;
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < n; j++) {
      ll sum = i * 4 + j * 7;
      if (n == sum) res = true;
    }
  }

  cout << (res ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef LOCAL
// #include "trace.h"
// #else
// #define trace(args...)
// #endif

#define int long long
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 1e9 + 7;
int gcd(int n, int m) {
	while (n) swap(n, m), n %= m;
	return m;
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}

void solve() {
	int n; cin >> n;
	int cnt = 0, x;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		if (x % 2 == 1 && i % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

int32_t main() {

	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def a_int(): return int(read())


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

K = np.array(list(map(int, list(input()))))
D = a_int()

'''
ある数xにおいて総和がDの倍数であるかの判定
x[0]+x[1]...+x[n] ≡ 0 (mod D) 各桁の和にMODを取れば良い。つまり桁ごとに処理できる

dp[i,j,k] ... K[:i]以下の整数のうち、k=mod Dとなるような数字の個数。j==1は上位桁が一致している場合の通りの個数。j==0は上位桁が一致しなくなったときの個数。

遷移
for l in range(10):
    dp[i+1,0,(k+l)%D] += dp[i,0,k] #1~9を考慮可能
for l in range(K[i]):
    dp[i+1,0,(k+l)%D] += dp[i,1,k] #1~K[i]-1をつけるとぴったりにならないグループへ行く

dp[i+1,1,(k+K[i])%D] += dp[i,1,k]
'''
# print(K, D)

from numba import njit


@njit('(i8[:],i8)', cache=True)
def solve(K, D):
    N = K.shape[0]
    dp = np.zeros((N + 1, 2, D), dtype=np.int64)
    dp[0, 1, 0] = 1
    for i in range(N):  # 各桁について
        for k in range(D):  # 各あまりについて処理
            for l in range(10):  # 各数字について処理
                dp[i + 1, 0, (k + l) % D] += dp[i, 0, k]  # 1~9を考慮可能
                if l < K[i]:
                    dp[i + 1, 0, (k + l) % D] += dp[i, 1, k]  # 1~9を考慮可能
                    # 1~K[i]-1をつけるとぴったりにならないグループへ行く
                dp[i + 1, 0, (k + l) % D] %= MOD
            # ぴったりグループ
            dp[i + 1, 1, (k + K[i]) % D] += dp[i, 1, k]
            dp[i + 1, 1, (k + K[i]) % D] %= MOD

    print((dp[-1, :, 0].sum() - 1) % MOD)  # -1は0の分


solve(K, D)


Measured memory_bytes: 131660