akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class B {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final long H = sc.nextInt();
        final long W = sc.nextInt();
        final long ans = (H / 2) * (W / 2) * 2 + (H % 2) * (W / 2) + (W % 2) * (H / 2) + (H % 2) * (W % 2);
        System.out.println(H == 1 || W == 1 ? 1 : ans);
    }
}
public class Main {
    public static void main(String... args) {
        B.main();
    }
}


Measured memory_bytes: 23892
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                ans += i;
            }
        }
        System.out.println(ans);
    }

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

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


Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
const ll INF = 1e9;

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b); 
}

bool is_prime(ll x){
    if(x==1) return false;
    for(ll i=2; i*i<=x;i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    fast_io
    
    ll W, H, x, y;
    cin>>W>>H>>x>>y;

    cout<<fixed<<setprecision(10)<<double(W)*double(H)/2.0<<" "<<(x+x==W&&y+y==H)<<endl;

    return 0;
}

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

void update(vector<int> &a, int i, int x) {
    a[i] = x;
}

int find(vector<int> &a, int s, int t) {
    int min = pow(2, 31) - 1;
    for(int i=s; i<=t; ++i) {
        if(a[i] < min) {
            min = a[i];
        }
    }
    return min;
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a;
    for(int i=0; i<n; ++i) {
        a.push_back(pow(2,31) - 1);
    }

    vector<int> com, x, y;
    for(int i=0; i<q; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        com.push_back(a);
        x.push_back(b);
        y.push_back(c);
    }

    for(int i=0; i<q; ++i) {
        if(com[i] == 0) {
            update(a, x[i], y[i]);
        } else if(com[i] == 1) {
            printf("%d\n", find(a, x[i], y[i]));
        }
    }

    return 0;
}

Measured memory_bytes: 4756
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a,b,c;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        if(a<b){
        	if(b<c)
        		System.out.println("Yes");
        	else
        		System.out.println("No");
        }
        else
        	System.out.println("No");
        sc.close();
    }
}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;
void solve()
{ll t,n,k,c=0;
 cin>>n>>k;
 string s,x;
 cin>>s;
 transform(s.begin()+k-1, s.begin()+k, s.begin()+k-1, ::tolower);
 cout<<s;
 return ;
}
int main()
{
fast
ll t=1;
while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    h,w = map(int, input().split())
    s = [input().rstrip() for i in range(h)]

    visited = [[0]*w for i in range(h)]
    dist = [[INF]*w for i in range(h)]

    que = deque([(0,0)])
    visited[0][0] = 1
    dist[0][0] = 0

    dx = (1, -1, 0, 0)
    dy = (0, 0, 1, -1)

    while len(que) > 0:
        x,y = que.popleft()
        if x == w-1 and y == h-1: # ゴールまで辿ったら
            break

        for k in range(4): # 上下左右4パターンの移動方法
            nx = x + dx[k]
            ny = y + dy[k]

            if 0<=nx<w and 0<=ny<h and s[ny][nx]=='.' and visited[ny][nx]==0:
                que.append((nx,ny))
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1

    if dist[h-1][w-1] == INF:
        print(-1)
    else:
        print(sum(s[i].count(".") for i in range(h)) - (dist[h-1][w-1]+1))


if __name__=="__main__":
    main(
    )


Measured memory_bytes: 73784
from collections import deque

def shortestpath(y0, x0):
    step_cnt = [[-1] * w for _ in range(h)]
    step_cnt[y0][x0] = 0
    q.append((y0, x0))
    while q:
        y, x = q.popleft()
        for i in range(4):
            y_next = y + dy[i]
            x_next = x + dx[i]
            if 0 <= y_next < h and 0 <= x_next < w\
            and maze[y_next][x_next] == '.'\
            and step_cnt[y_next][x_next] == -1:
                q.append((y_next, x_next))
                step_cnt[y_next][x_next] = step_cnt[y][x] + 1
                    
    return step_cnt[y][x]

h, w = map(int, input().split())      
maze = [[x for x in input()] for _ in range(h)]
dy = [-1, 0, 1, 0]
dx = [0, -1, 0, 1]
q = deque()

max_steps = -1
for y0 in range(h):
    for x0 in range(w):
        if maze[y0][x0] != '#':
            max_steps = max(max_steps, shortestpath(y0, x0))

print(max_steps)

Measured memory_bytes: 3316
// Hack it and have it ;) //
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows!* * * * * * */
#include      <bits/stdc++.h>
using namespace std;
#define IOS       ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC      cout.precision (10); cout << fixed
#ifdef CONVICTION
#include "/home/convict/Dropbox/myfiles/sport_coding/cplib/snippets/debug.h"
#else
#define debug(x...)
#endif
//Don’t practice until you get it right. Practice until you can’t get it wrong

void preproc() {
}

void solve() {
   int N, K;
   cin >> N >> K;
   vector <int> ar(N);
   for (int i = 0; i < N; ++i) {
      cin >> ar[i];
   }
   sort(ar.begin(), ar.end());
   int sm = 0;
   for (int i = 0; i < K; ++i) {
      sm += ar[i];
   }
   cout << sm << '\n';
}

signed main() {
  IOS; PREC;
  preproc();

  int tc = 1;
  // cin >> tc;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    // cout << "Case #" << Tt << ": ";
    solve();
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
	int N, M; scanf ("%d %d", &N, &M);
	int L = (N - 1) / 2;

	int u = (L + 1) / 2, v = L / 2;
	
	for (int s = u, e = u + 1; s >= 1; s--, e++){
		printf ("%d %d\n", s, e);
		if (--M == 0) return 0;
	}

	for (int s = 2 * u + v, e = s + 2; s > 2 * u; s--, e++){
		printf ("%d %d\n", s, e);
		if (--M == 0) return 0;
	}

	return 0;
}

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

int main() {
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i > 0 && i < H-1 && j > 0 && j < W-1){
                    cout << ".";
                }
                else cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

bool f(ll n, ll s, ll t) {
	return n <= (s + 1) * t && s >= 0 && n >= 0;
}

int main() {
	int Q; scanf("%d", &Q);
	while(Q--) {
		ll A, B, C, D; scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		ll t = max((B + A) / (A + 1), (A + B) / (B + 1));
		if(A >= B) {
			int l = 0, r = B + 1;
			while(l <= r) {
				int m = l + r >> 1;
				if(f(B + 1 - m, A - t * m, t)) l = m + 1;
				else r = m - 1;
			}
			int x = r;
			l = 0, r = t - 1;
			while(l <= r) {
				int m = l + r >> 1;
				if(f(B + 1 - x - 1, A - t * x - m, t)) l = m + 1;
				else r = m - 1;
			}
			int y = r;

			for(ll i = C; i <= D; i++) {
				if(i <= (t + 1) * x) {
					printf(i % (t + 1) ? "A" : "B");
				}
				else if(i <= (t + 1) * x + y) printf("A");
				else if(i == (t + 1) * x + y + 1) printf("B");
				else {
					int z = A + B - i + 1;
					printf(z % (t + 1) ? "B" : "A");
				}
			}
		}
		else {
			int l = 0, r = A + 1;
			while(l <= r) {
				int m = l + r >> 1;
				if(t * (A - t * m) + m < B || A < t * m) r = m - 1;
				else l = m + 1;
			}
			int x = r;
			l = 0, r = t - 1;
			while(l <= r) {
				int m = l + r >> 1;
				if(t * (A - t * x - m) + x < B || A < t * x + m) r = m - 1;
				else l = m + 1;
			}
			int y = r;

			for(ll i = C; i <= D; i++) {
				if(i <= (t + 1) * x) {
					printf(i % (t + 1) ? "A" : "B");
				}
				else if(i <= (t + 1) * x + y + 1) printf("A");
				else {
					int z = A + B - i + 1;
					printf(z % (t + 1) ? "B" : "A");
				}
			}
		}

		puts("");
	}
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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 main() {
    int n;
    string s;
    cin >> n;
    int ans = 0;
    int ab =0, a=0, b=0;
    rep(i, n) {
        cin >> s;
        int size = s.size();
        rep(i, size-1) {

            if (s[i] == 'A' and s[i+1] == 'B') {
                ++ans;
            }
        }
            
        if (s[0] == 'B' and s[size-1] == 'A') {
            ++ab;
        } else if (s[0] == 'B') {
            ++b;
        } else if (s[size-1] == 'A') {
            ++a;
        }
    }

    if (ab == 0) {
        ans += min(a, b);
    } else if (ab > 0 ) {
        if ( a > 0 or b > 0) {
            ans += ab + min(a, b);
        } else {
            ans += ab - 1;
        }
    }

    cout << ans << endl;
}



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

using namespace std;
double condition = 0.0;

void func()
{
	int K,N;
	cin >> K >> N;
	vector<int>A(N);

	for (int i = 0; i < N; i++)
		cin >> A[i];

	int diff = K-A[N-1]+A[0];
	for (int i = 1; i < N; ++i)
		diff = max(diff, A[i]-A[i-1]);

	cout << K - diff << endl;
}

int main() {
//	while(1)
	func();
	return 0;
}


Measured memory_bytes: 3616
a=int(input())
b=list(map(int,input().split()))
c=0
for i in range(a):
  if b[i]%2==0:
    if b[i]%3==0 or b[i]%5==0:
      c=c+1
  else:
    c=c+1
if c==a:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 9092
def main():
    N, M, K = map( int, input().split())
    A = list( map( int, input().split()))
    B = list( map( int, input().split()))
    indb = M-1
    now = sum(B)
    count = M
    while now > K:
        now -= B[indb]
        count -= 1
        indb -= 1

    ans = count
    for a in A:
        # print(ans, now)
        now += a
        count += 1
        while now > K and indb >= 0:
            now -= B[indb]
            count -= 1
            indb -= 1
        if now <= K:
            if ans < count:
                ans = count
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 40448
using System;

namespace lisson2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);
            int s = -1;
            if (X % Y != 0)
            {
                s = X;
            }
            Console.WriteLine(s);

        }
    }
}


Measured memory_bytes: 11092
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    a, b = f.read_int_list()
    return max([a+b, a-b, a*b])


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

int main() {
    int n, p; cin >> n >> p;
    bool odd = false;
    for (int i = 0; i < n; i++) {
        int a; cin >> a; odd |= a & 1;
    }
    long long ans = 1LL << (n - 1);
    if (!odd) {
        if (p == 0) cout << ans * 2 << endl;
        else cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N = 200100;
int n , a[N] , q ;
ll sum [N];
int main ( ){
  cin >> n ;
  for  (int i = 1;  i <= n ;i++ ) {
        cin >> a[i] ;
      sum[i] = sum[i-1] + a[i] ;
  }
  ll mn = 1LL *inf*inf  ;
  for ( int i = 1 ; i <= n-1 ; i ++ ){
      mn = min ( mn , abs(sum[i]-(sum[n]-sum[i])));
  }
  cout << mn ;
return 0 ;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>

using namespace std; 
int N; int cnt = 0;
void dfs(bool flag3, bool flag5, bool flag7,long long X){
  if( X > N){ return ;}
  if(flag3 && flag5 && flag7){cnt++;}
  
  dfs(true,flag5,flag7,10*X + 3);
  dfs(flag3,true,flag7,10*X + 5);
  dfs(flag3,flag5,true,10*X + 7);}

int main(){
  cin >> N;
  dfs(0,0,0,0);
  
  cout <<cnt << endl;
  return 0;}

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

namespace ABC130A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nx[0];
            var x = nx[1];
            var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var d = 0;
            var result = n+1;
            for(var i = 1; i < n + 1; i++)
            {
                d = d + l[i - 1];
                if (d > x)
                {
                    result = i;
                    break;
                }
            }
            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <unordered_map>
#include <utility>

using namespace std;

typedef long long ll;

ll INF = 1e15;

unordered_map<ll,ll> us[100000];
bool b[100000];
ll p[100000];
ll N,M;

bool dfs(ll n){
    auto itr = us[n].begin();
    for(;itr != us[n].end();itr++){
        pair<ll,ll> rd = *itr;
        if(p[rd.first] == INF){
            p[rd.first] = p[n] + rd.second;
            if(!dfs(rd.first)) return false;
        }else{
            if(p[rd.first] != p[n] + rd.second){
                return false;
            }
        }
    }
    return true;
}

int main(){
    cin >> N >> M;
    ll l,r,d;
    for(int i=0;i<M;i++){
        cin >> l >> r >> d;
        us[l-1][r-1] = d;
        us[r-1][l-1] = -d;
    }
    for(int i=0;i<N;i++) p[i] = INF;
    for(int i=0;i<N;i++){
        if(p[i] != INF) continue;
        p[i] = 0;
        if(dfs(i)) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 27136
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

char board[1005][1005];

int main() {
  // ios_base::sync_with_stdio(0);

  int N, M, A, B;
  scanf("%d%d%d%d", &N, &M, &A, &B);

  REP(i,N)REP(j,M) board[i][j] = '.';

  if (M%2) {
    for (int i = 0; i+1 < N; i += 2) {
      if (B > 0) {
        board[i][0] = '^';
        board[i+1][0] = 'v';
        --B;
      }
    }

    if (B % 2 && M > 1 && N >= 2) {
      board[N-2][M-1] = '^';
      board[N-1][M-1] = 'v';
      --B;
    }
  }

  REP(i,N-1)REP(j,M) {
    if (board[i][j] == '.' && board[i+1][j] == '.' && B > 0) {
      board[i][j] = '^';
      board[i+1][j] = 'v';
      --B;
    }
  }
  REP(i,N)REP(j,M-1) {
    if (board[i][j] == '.' && board[i][j+1] == '.' && A > 0) {
      board[i][j] = '<';
      board[i][j+1] = '>';
      --A;
    }
  }

  if (A > 0 || B > 0) {
    printf("NO\n");
    return 0;
  }

  printf("YES\n");
  REP(i,N) printf("%s\n", board[i]);
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
long long recursive(long long health){
  if(health == 1) return 1;
  else health = (recursive(health / 2) * 2) + 1;
  return health;
}
int main(){
  long long H;
  cin >> H;
  cout << recursive(H) << endl;
}

Measured memory_bytes: 256
/*
    Author  :   jignesh1604
    College :   SVNIT
*/

#include<bits/stdc++.h>
using namespace std;

void solve() {
    long long int n , w , i , j;
    cin >> n >> w;
    long long int val[n+1] , wei[n+1];
    for(i = 0 ; i < n ; i++) {
        cin >> wei[i] >> val[i];
    }
    vector<vector<long long int>> dp(2 , vector<long long int> (100005 , INT_MAX));
    dp[0][0] = 0;
    for(i = 1 ; i <= n ; i++) {
        for(j = 0 ; j <= 100000 ; j++) {
            if(val[i-1] <= j) {
                dp[i%2][j] = min(wei[i-1] + dp[(i-1)%2][j-val[i-1]] , dp[(i-1)%2][j]);
            }
            else {
                dp[i%2][j] = dp[(i-1)%2][j];
            }
            // cout << i << " " << j << " " << dp[i%2][j] << "\n";
        }
    }
    long long int ans = 0;
    for(i = 1 ; i <= 100000 ; i++) {
        // cout << dp[]
        if(dp[0][i] <= w) ans = max(ans , i);
        if(dp[1][i] <= w) ans = max(ans , i);
    }
    cout << ans << "\n";
}

int main() {
    long long int tc = 1;
    // cin >> tc;
    while(tc-- > 0) {
        solve();
    }
}

Measured memory_bytes: 5620
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    bool answer = true;
    int count = 0;
    for (int i = n - 2; i >= 0; --i) {
        if (h[i] > h[i + 1]) {
            if (h[i] - h[i + 1] > 1) {
                answer = false;
                break;
            }
            if (++count > 1) {
                answer = false;
                break;
            }
        }
        if (h[i] < h[i + 1]) count = 0;
    }
    cout << (answer ? "Yes" : "No") << endl;
}


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

using namespace std;
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)

const int MN = 100010;
int n;
vector<int> g[MN];

int match(int v, int p) {
    int umt = 0;
    foreach(u, g[v]) {
        if (*u == p) continue;
        umt += match(*u, v);
    }
    if (umt >= 2) return umt;
    return 1-umt;
}

int main() {
    scanf("%d", &n);
    rep(i, 0, n-1) {
        int a, b;
        scanf("%d %d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (match(0, -1)) puts("First");
    else puts("Second");
    return 0;
}

Measured memory_bytes: 5888
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        h: u64,
        w: u64,
    };

    if h == 1 || w == 1 {
        println!("1");
    } else {
        let a =  ((w + 1) / 2) * ((h + 1) / 2);
        let b =  (w / 2) * (h / 2);
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int N,D;
    cin >> N >> D;
    vector<vector<int>> data(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> data.at(i).at(j);
        }
    }
    int ans=0; //答え
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            ll sum = 0; //ルートの中身
            for (int k = 0; k < D; k++) {
                sum += pow(data[i][k] - data[j][k],2);
            }
            ld x = sqrtl(ld(sum));
            if(floor(x)==x) ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 384
import java.util.*;
class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int num;
		int sum = a + b + c;
		if(a>b){
			num = a;
		}else{
			num = b;
		}
		if(c>num){
			num = c;
		}
		sum = sum - num;
		for(int y=0; y<x; y++){
			num = num * 2;
		}
		System.out.println(num + sum);
	}
}


Measured memory_bytes: 23124
dic = {}
s = input()
cue = 0
for i in s:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for i in dic:
    if dic[i] % 2 != 0:
        cue = 1
        break

if cue == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int f(int n, int cnt) {
	string s = to_string(n);
	if (s.size() == 1)return cnt;
	int ret = 0;
	rep(i, 1, s.size()) {
		string a = s.substr(0, i), b = s.substr(i);
		dump(a);
		dump(b);
		ret = max(ret, stoi(a)*stoi(b));
	}
	return f(ret, cnt + 1);
}

signed main() {
	int Q; cin >> Q;
	vector<int> N(Q); rep(i, 0, Q) { cin >> N[i]; }
	rep(i, 0, Q) {
		cout << f(N[i], 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
N, Q = map(int, input().split())
S = input()
l = [None] * Q
r = [None] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())
    l[i] -= 1
    r[i] -= 1

sumbgn = [0] * N
sumend = [0] * N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        sumbgn[i-1] = sumbgn[i-2] + 1 if i-2 >= 0 else 1
        sumend[i] = sumend[i-1] + 1
    else:
        sumbgn[i-1] = sumbgn[i-2] if i-2 >= 0 else 0
        sumend[i] = sumend[i-1]

for i in range(Q):
    sumr = sumend[r[i]]
    suml = sumbgn[l[i]-1] if l[i] > 0 else 0
    print(sumr - suml)



Measured memory_bytes: 16564
#include <stdio.h>
#define P(s) {printf(s "\n");continue;}
int main(void){int m,f,r,s;for(;;){scanf("%d %d %d",&m,&f,&r);if((s=m+f)+r==-3)exit(0);if((m==-1)|(f==-1)|(s<30))P("F")if(s>=80)P("A")if(s>=65)P("B")if((s>=50)|(r>=50))P("C") P("D")}}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
int mx = 1e18;
int main()
{
    int n;

	cin >> n;
	vector<int>h(n);
	for (int i = 0; i < n; i++)cin >> h[i];
	reverse(h.begin(), h.end());
	int ans  = 0;
	int val = 0;
	for (int i = 1;i < n; i++)
    {
        if(h[i-1]<= h[i])val++;
        else val = 0;
        ans = max(val, ans);
    }
	cout << ans;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<sstream>
#include<cstdlib>
using namespace std;
int n,t,maxn=1e9;
void run()
{
    cin>>n>>t;
    for(int i=1; i<=n; i++)
    {
    	int ci,ti;
    	cin>>ci>>ti;
    	if(ti<=t) maxn=min(maxn,ci);
    }
    if(maxn!=1e9)
    cout<<maxn;
    else cout<<"TLE";
}
int main()
{
	run();
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var W = cin.ReadLong;
            var H = cin.ReadLong;
            var x = cin.ReadLong;
            var y = cin.ReadLong;

            double Area = (double)W * (double)H / 2.0;
            int MultiWays;

            if (W == x * 2 && H == y * 2) {
                MultiWays = 1;
            } else {
                MultiWays = 0;
            }

            Console.WriteLine("{0} {1}", Area, MultiWays);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
using namespace std;
long long ans = 0;
void dfs(long long a, long long b) {
	if (b > a)dfs(b, a);
	if (b == a) ans += b;
	if (a > b) {
		long long tmp = 1+((a - b-1) / b);
		ans += tmp * 2 * b;
		dfs(a - tmp*b, b);
	}
}
int main() {
	long long n, x;
	cin >> n >> x;
	dfs(x, n - x);
	cout << ans + n;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define f(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
#define printv(v) for(auto it : v) cout<<it<<" ";


//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;
const long long int MOD = 1e9+7;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
int n;
cin>>n;
vi v(n);
for(int i = 0 ;i<n ;i ++)
cin>>v[i];
ll sum = 0 ; 
int mx = v[0];
for(int i = 1;i<n ;i ++)
{
    sum+=(max(mx-v[i],0));
    mx = max(v[i],mx);
}
cout<<sum<<endl;

}
}


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

int main() {
	//入力
	int n, m;
	cin >> n >> m;

	int a[50], b[50], c[50], d[50];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	//計算
	int ans[50];
	for (int i = 0; i < n; i++) {
		ans[i] = 1;
		int q = 400000000;

		for (int j = 0; j < m; j++) {
			int p = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (q > p) {
				q = p;
				ans[i] = j + 1;
			}
		}
	}

	//出力
	for (int i = 0; i < n; i++) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	string ans = "Yes";
	if (S[2] != S[3] || S[4] != S[5])
		ans = "No";
	cout << ans << endl;
	return 0;
}

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

int N;
vector<int> a, b;

int main() {
    cin >> N; a.resize(N); b.resize(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = N-1; i >= 0; i--) {
        int cnt = 0;
        for (int j = i+1; j <= N; j += i+1) if (b[j-1]) cnt = !cnt;
        if (a[i] != cnt) b[i] = 1;
    }
    int M = accumulate(b.begin(), b.end(), 0);
    cout << M << endl;
    for (int i = 0; i < N; i++) {
        if (b[i]) cout << i+1 << " ";
    }
    if (M != 0) cout << endl;
    return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		if (n == 7 || n == 3 || n == 5) {
			out.println("YES");
		} else {
			out.println("NO");
		}
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;


int main(int argc, char **argv) {
  char c;
  int N = 0;
  char first, last;
  while ((c = getc(stdin)) != EOF && (c >= 'a' && c <= 'z')) {
    if (N == 0) first = c;
    N++;
    last = c;
  }

  cout << ( ((N <= 2) || !((first == last) ^ (N & 1)))? "Second" : "First" ) << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#define MAX_ELEMENTS 500010
#define INFTY  1000000010
int n,count;
void merge(int A[],int left,int mid,int right){
  
    int n1, n2,i,j,k;

    n1 = mid - left;
    n2 = right - mid;

int L[n1+1];
int R[n2+1];
    //L[0...n1], R[0...n2] を生成
    for(i=0; i<=n1-1; i++)  L[i] = A[left + i];
    for(i=0; i<=n2-1; i++)  R[i] = A[mid + i];
    
    L[n1] = INFTY;
    R[n2] = INFTY;

    i = 0;
    j = 0;

    for(k=left; k<=right-1; k++){
        count++;
        if(L[i]<=R[j])   A[k] = L[i++];
        else             A[k] = R[j++];
    }
}

void mergeSort(int A[],int left,int right){
    int mid;
    if(left+1 < right){
        mid = left+(right-left)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(void){
    int i;
    int S[MAX_ELEMENTS];

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

    mergeSort(S,0,n);
    for(i=0; i<n; i++) printf(i != 0 ? " %d" : "%d", S[i]);
    printf("\n", count);
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main(){
    int a,s=0;
    cin >> a;
    int b[a];
    rep(i,a){
        cin >> b[i];
    }
    rep(i,a){
        rep(j,a){
            if(i!=j&&i<j) s += b[i]*b[j];
        }
    }
    cout << s;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a;
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b, k;
	cin >> a >> b >> k;
	if (k > a)
	{
		
		k -= a;
		a = 0;
	}
	else
	{
		a -= k;
		k = 0;
	}
	if (k > b)
	{
		
		k -= b;
		b = 0;
	}
	else
	{
		b -= k;
		k = 0;
	}
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

ll solve(ll a, ll b){
  if(a == b) return a;
  if(a > b) swap(a,b);

  ll k = b/a;
  if(b == a*k) return a * (2*k-1);
  return solve(a,b-a*k) + 2*k*a;
}

int main(){
  ll n,x;
  cin >> n >> x;

  cout << solve(x,n-x) + n << endl;
}


Measured memory_bytes: 256
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[102];
    gets(a);
    int x=strlen(a),i,j;
    for(i=0,j=x-1 ; i<=x/2,j>=x/2 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(i=0,j=x/2-1 ; i<=x/2-1,j>=0 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(i=x/2+1,j=x-1 ; i<=x-1,j>=x/2+1 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

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

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)


int main(){
	int N;
	cin >> N;
	vector<ll>a(N);
	rep(i, N)cin >> a[i];
	ll money=1000;
	ll kabu=0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] < a[i + 1]) {
			kabu += money / a[i];
			money=money%a[i];
		}
		else {
			money += kabu * a[i];
			kabu = 0;
		}
	}
	money += kabu * a[N - 1];
	cout << money;
}
	



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    bool me = false;
    rep(i, n) {
        cin >> a[i];
        if (a[i]&1) me = true;
    }
    cout << (me ? "first" : "second") << endl;

}

Measured memory_bytes: 640
l = list()

for i in range(3):
    l.append(list(map(int, input().split())))

if l[0][0]-l[1][0] == l[0][1]-l[1][1] == l[0][2]-l[1][2]:
    if l[2][0]-l[1][0] == l[2][1]-l[1][1] == l[2][2]-l[1][2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

int main()
{
    int n, k;
    cin >> n >> k;

    int ans = 0;
    rep (i, n)
    {
        int h;
        cin >> h;
        if (h >= k)
            ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		int t = sc.nextInt();
		BigDecimal r = new BigDecimal(Integer.toString(t));
		BigDecimal area = new BigDecimal("0");
		BigDecimal two = new BigDecimal("2.0");
		BigDecimal pi = new BigDecimal(Double.toString(Math.PI));
		area = two.multiply(r).multiply(pi);
		System.out.println(area);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 33660
n=int(input())
s=[]
for i in range(n):
  a,b=map(int,input().split())
  s.append([a+b,a,b])
s=sorted(s,key=lambda x: x[0],reverse=True)
tk,ao=0,0
for i in range(n):
  if i%2==0:
    tk+=s[i][1]
  else:
    ao+=s[i][2]
print(tk-ao)


Measured memory_bytes: 25224
#include <stdio.h>
#define TRUE 1
#define FALSE 0

int solve(int,int);
int A[20],n;

int main(){
  int q,i,j,m[200],y;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&m[j]);
  }

  for(j=0;j<q;j++){
    y = solve(0,m[j]);
    if(y == 1){
      printf("yes\n");
    }
    else if(y == 0){
      printf("no\n");
    }

  }
  return 0;
}
  

int solve(int i, int m){
  int res;
  if(m == 0) return TRUE;
  if(i >= n ) return FALSE;

  res = solve(i+1, m) || solve(i+1, m-A[i]);

  return res;
}



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main()
{
	int N;
	unsigned long long sum=0;
	int d[100];
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>d[i];
	}
	for(int i=0;i<N-1;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			sum+=d[i]*d[j];
			
		}
	}
	cout<<sum; 
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  string S;
  int n,ans=-999,j;
  std::cin  >> n >> S;

  for(int i=1; i<n; i++){
    int a[26]={},b[26]={},cnt=0;
    for(int j=0; j<i; j++) a[S[j]-'a']++;
    for(int j=i; j<n; j++) b[S[j]-'a']++;

    for(int i=0; i<26; i++){
      if(a[i]>0 && b[i]>0) cnt++;
    }
    ans=max(ans,cnt);

  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256