akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL n, m;
    cin >> n >> m;
    VVL e(n);
    VL vis(n, 0);
    for (int i = 0; i < m; i++) {
        LL val1, val2;
        cin >> val1 >> val2;
        --val1;
        --val2;
        e[val1].pb(val2);
        e[val2].pb(val1);
    }

    LL currElems;
    function<void(LL)> dfs = [&](LL index)
    {
        vis[index] = true;
        currElems++;
        for (auto neigh : e[index]) {
            if (vis[neigh]) {
                continue;
            }
            dfs(neigh);
        }
    };

    LL ans = 0;
    for (int i = 0; i < n; i++) {
        currElems = 0;
        if (!vis[i]) {
            dfs(i);
        }
        ans = max(ans, currElems);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24692
import java.util.*;
import java.lang.Math.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		// スペース区切りの整数の入力
		int B = sc.nextInt();

		int distance = Math.abs(A-B);
		int harfDistance = distance / 2;

		int left = Math.max(A, B) - harfDistance;
		int right = Math.min(A, B) + harfDistance;

		if(left == right){
			System.out.println(left);
		}else{
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 22484
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	long long int N, p, maep = 0, mmaep = 0 , c = 0, a;
	bool flag = true;
	cin >> N;
	for (long long int i = 0; i < N; i++)
	{
		cin >> p;
		if (i + 1 != p)c++;
	}
	if (c <= 2)cout << "YES";
	else cout << "NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i+=2) {
        if(a[i] % 2 == 1){
            ans++;
        }
    }
    printf("%d\n", ans);

}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

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

    double A,B; cin >> A >> B;

    FOR(i,1,1000000){
        if(floor(double(i)*0.08) == A and floor(double(i)*0.10) == B and floor(double(i)*0.08) > 0){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public 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();
    
    if(A==B && A!=C){
      System.out.println("Yes");
    }else if(A==C && A!=B){
      System.out.println("Yes");
    }else if(B==C && B!=A){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
    

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

int main(){
    string s;
    cin>>s;
    int cnt=0;
    rep(i,s.size()){
        cnt+=s[i]-'0';
    }
    if(cnt%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
   if(a==b)
    {
        if(a==c)
            printf("No\n");
        else
            printf("Yes\n");
    }
else//a!=b
{
    if(a==c)
        printf("Yes\n");
    else if(b==c)
    printf("Yes\n");
    else
    printf("No\n");
}
    return 0;
}




Measured memory_bytes: 128
S = input()
dp = [0] * (len(S) + 1)
dp[1] = 1

if S[0] == S[1]:
	dp[2] = 1
else:
	dp[2] = 2

for i in range(3, len(S) + 1):
	if S[i - 1] != S[i - 2]:
		dp[i] = dp[i - 1] + 1
	else:
		dp[i] = dp[i - 3] + 2

print(dp[-1])

Measured memory_bytes: 11240
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=(int)3e3+5,INF=(int)-1e15;

int n,m;




int a[N];

int dp[N][N];


int solve(int l,int r)
{
  //  trace2(l,r);
    if(l>r)return 0;
    
    int &ans=dp[l][r];
    //cout<<dp[l][r]<<" ";
   // cout<<"h1\n";
    if(ans!=(-1000000000000000))return ans;
    
   
    int op1=a[l]-solve(l+1,r);
    int op2=a[r]-solve(l,r-1);
    
    return ans=max(op1,op2);
}


void solve()
{
    
    cin>>n;
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=-1000000000000000;
    
    for(int i=1;i<=n;i++)cin>>a[i];
    
    cout<<solve(1,n);
    
    
    
    
    
    
   
    
   
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}


Measured memory_bytes: 74204
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner	sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int c = 0;
		for(int i=0;i<s.length();i++){
			char ch1=s.charAt(i);
			char ch2=t.charAt(i);
			if(ch1!=ch2)
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 31932
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  cout << (long long) (1LL * pow(2, m) * (m * 1900 + (n - m) * 100)) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();
        long k = sc.nextLong();

        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        List<Integer> s = new ArrayList<>();

        int[] ord = new int[n+1];
        for (int i = 0; i < n+1; i++) {
            ord[i] = -1;
        }

        int c = 1;
        int l = 0;

        int v = 1;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.add(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];

        if (k < l) {
            System.out.println(s.get((int)k));
        } else {
            k -= l;
            k %= c;
            System.out.println(s.get((int)k+l));
        }
    }
}


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

const int mod = 1000000007;
const int MAXN = 10004;
const int MAXM = 503;

string pattern, A, B;
vector<int> next;
int dp[2][MAXM][2][2], dp2[2][MAXM][2][2];

void make() {
  pattern += "$";
  next = vector<int>(pattern.size()+1);
  next[0] = -1;
  for(int i = 0, j = -1; i < pattern.size(); ++i, ++j, next[i] = j)
    while(j >= 0 && pattern[i] != pattern[j]) j = next[j];
  pattern.resize(pattern.size() - 1);
}

int calc(const string &X) {
  memset(dp, 0, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  dp[0][0][0][0] = 1;
  for(int i = 0; i < X.size(); ++i) {
    const int p = i % 2;
    const int q = (i + 1) % 2;
    for(int j = pattern.size()-1; j >= 0; --j) {
      for(int k = 0; k < 2; ++k) {
        for(int z = 0; z < 2; ++z) {
          dp[q][j][k][z] = 0;
          dp2[q][j][k][z] = 0;
        }
      }
    }
    for(int j = pattern.size()-1; j >= 0; --j) {
      for(int k = 0; k < 2; ++k) {
        for(int z = 0; z < 2; ++z) {
          for(char d = '0'; d <= '9'; ++d) {
            if(!k && X[i] < d) break;
            int nk = k || X[i] != d;
            int nz = z || d != '0';
            int ni = i, nj = j;
            int add = 0;
            if(!nz) {
              ni = i+1; nj = 0;
            } else {
              while(ni == i) {
                if(d == pattern[nj]) {
                  ++ni;
                  ++nj;
                } else if(nj == 0) {
                  ++ni;
                  nj = 0;
                } else {
                  nj = next[nj];
                }
              }
            }
            if(nj == pattern.size()) {
              add = 1;
              nj = next[nj];
            }
            ( dp[q][nj][nk][nz] += dp[p][j][k][z] ) %= mod;
            ( dp2[q][nj][nk][nz] +=
              (dp2[p][j][k][z] + add * dp[p][j][k][z] % mod) % mod ) %= mod;

          }
        }
      }
    }
  }
  int res = 0;
  for(int j = pattern.size()-1; j >= 0; --j) {
    for(int k = 0; k < 2; ++k) {
      for(int z = 0; z < 2; ++z) {
        ( res += dp2[X.size()%2][j][k][z] ) %= mod;
      }
    }
  }
  return res;
}

/*
33
133
233
330
331
332
333
the number of "33" in [0,333] is 8
*/

int main() {
  while(cin >> A >> B >> pattern) {
    make();
    int res = (calc(B) - calc(A) + mod) % mod;
    for(int i = 0; i < A.size(); ++i) {
      if(A.substr(i, pattern.size()) == pattern) {
        ( res += 1 ) %= mod;
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>
int main(){
long long int n,o;
scanf("%lld %lld",&n,&o);
long long int a[n];
for (long long int i=0;i<n;i++){
	scanf("%lld",&a[i]);
}
for(long long int i=o;i<n;i++){
	if(a[i-o]<a[i]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}
return 0;
}


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

int main(void) {
    int A,B;
    int cnt = 0;
    cin >> A >> B;
    for(int i=A;i<=B;i++) {
        if(((i/10000) == (i%10)) && (((i/1000)%10) == ((i/10)%10))){
//printf("%d: %d\n",cnt, i);
            cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a = in.nextLong();
            long b = in.nextLong();
            int[] p = new int[n];
            for (int i = 0; i < n; ++i) {
                p[i] = in.nextInt();
            }
            long[] best = new long[n + 2];
            for (int i = 0; i < n + 1; ++i) {
                best[i + 1] = Long.MAX_VALUE;
                long extra = 0;
                for (int j = i - 1; j >= -1; --j) {
                    if (i == n || j < 0 || p[j] < p[i]) {
                        best[i + 1] = Math.min(best[i + 1], best[j + 1] + extra);
                    }
                    if (j >= 0) {
                        if (i == n || p[j] < p[i]) {
                            extra += b;
                        } else {
                            extra += a;
                        }
                    }
                }
            }
            out.println(best[n + 1]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

    }
}



Measured memory_bytes: 25812
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main(){
	int n,ans=0;
	cin>>n;
	a[0]=n/1000;
	a[1]=n/100%10;
	a[2]=n/10%10;
	a[3]=n%10;
	for(int i=0;i<4;i++){
		if(a[i]==2){
			ans++;
		} 
	}
	cout<<ans;
	return 0;
} 

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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int x,a[210000],n,check[210000]={0},sum=0,temp,k,i;

	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
  qsort(a,n,sizeof(int),cmp);
  
  for(i=0;i<k;i++){
    sum+=a[i];
  }
  printf("%d",sum);
return 0;
}


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

int main() {
  int y, m, d, t;
  scanf("%d/%d/%d", &y, &m, &d);
  t = 10000 * y + 100 * m + d;
  if (20190430 >= t)
    cout << "Heisei";
  else
    cout << "TBD";
  return 0;
}

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

namespace ABC_143A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A,B;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            if (A < 10 && A > 0 && B < 10 && B > 0)
            {
                Console.WriteLine(A * B);
            }

            else
            {
                Console.WriteLine(-1);
            }

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 13140
def main():
    str = input()
    q = int(input())
    for _ in range(0, q):
        queries = input().split()
        command = queries[0]
        if command == 'print':
            a = int(queries[1])
            b = int(queries[2])
            print(str[a:b + 1])
        elif command == 'reverse':
            a = int(queries[1])
            b = int(queries[2])
            str = str[:a] + ''.join(list(reversed(str[a:b + 1]))) + str[b + 1:]
        elif command == 'replace':
            a = int(queries[1])
            b = int(queries[2])
            p = queries[3]
            str = str[:a] + p + str[b + 1:]

if __name__ == '__main__':
    main()



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

bool check(string S){
  if(S[0]!='A') return false;
  int C=0;
  for (int i = 2 ; i < S.length()-1; i++) {
    if(S[i]=='C'){
      C++;
    }
  }
  if(C!=1) return false;
  int upper=0;
  for (int i = 0; i < S.length(); i++) {
    if(S[i]>='A'&&S[i]<='Z'){
      upper++;
    }
  }
  if(upper!=2) return false;
  return true;
}

int main(){
  string S;
  cin >> S;
  if(check(S)){
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int x;
    int a;
    int b;
    cin >> x >> a >> b;
    int ab = abs(x - a);
    int ba = abs(x - b);
    if(ab < ba){
        cout << "A" << endl;
    }
    else{
        cout << "B" << endl;
    }
}

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

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

const int N = 1e5 + 11;
const int M = 1e6 + 11;
const int MOD = 1e9 + 7;

int main(int argc, char **args){
    int x, y, z; 
    cin >>x >>y >>z;
    swap(x, y);
    swap(x, z);
    cout <<x <<" " << y<<" " <<z<<"\n"; 
return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k,ret=0,h; cin>>n>>k;
	for (int i=0; i<n; i++) {
		cin>>h;
		if(h>=k) ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[2000],x,y;
int main(void){
    cin>>n>>x>>y;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    if(n==1){
        cout<<abs(s[0]-y)<<endl;
        return 0;
    }
    cout<<max(abs(s[n-1]-y),abs(s[n-1]-s[n-2]))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, k, num[26], tag, w, ano;
int main()
{
	scanf("%d%d", &n, &m);
	if (n & 1)
		tag += m / 2;
	if (m & 1)
		tag += n / 2;
	ano = n & m & 1;
	for (int i = 1; i <= n * m; i++)
	{
		char s = 0;
		while (!isalpha(s))
			s = getchar();
		num[s - 'a']++;
	}
	for (int i = 0; i < 26; i++)
	{
		w = num[i] & 3;
		if (w & 1 && ano)
		{
			w--;
			ano--;
		}
		if (w == 2)
		{
			if (tag)
				tag--;
			else
				return puts("No"), 0;
		}
		if (w & 1)
			return puts("No"), 0;
	}
	puts("Yes");
}

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

int main() {
  bool a = false;
  bool b = false;
  
  string s; cin >> s;
  for (char c : s) {
    if (c == 'A') a = true;
    if (c == 'B') b = true;
  }
  
  if (a and b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N), DP(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  DP.at(0) = 0;
  DP.at(1) = abs(H.at(1) - H.at(0));
  for (int i = 2; i < N; i++) {
    DP.at(i) = min(DP.at(i - 2) + abs(H.at(i) - H.at(i - 2)),
                   DP.at(i - 1) + abs(H.at(i) - H.at(i - 1)));
  }
  cout << DP.at(N - 1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}



int main(){

ios::sync_with_stdio(false);
cin.tie(0);
int s,w;

cin>>s>>w;

if(w>=s){
cout<<"unsafe"<<endl;
}else{
cout<<"safe"<<endl;
}

}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



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

typedef long long ll;

int n; 
int h[100];

int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }

    int res = h[0];

    for (int i = 1; i < n; i++){
        if (h[i] > h[i-1] > 0){
            res += h[i] - h[i-1];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]

ans = 0
prev = 0
for item in a:
    if item != prev + 1:
        ans += 1
    else:
        prev += 1
if ans == n:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 25748
#include <stdio.h>
#define GLAD_VALUE_500YEN 1000
#define GLAD_VALUE_5YEN   5
#define GOLD_COIN_500YEN  500
#define GOLD_COIN_5YEN    5

int main(void)
{
	int x, happy500, happy5;

	scanf("%d", &x);
	
	/* 500円玉による嬉しさの合計 */
	happy500 = GLAD_VALUE_500YEN * (x / GOLD_COIN_500YEN);

	x = x % 500;

	/* 5円玉による嬉しさの合計 */
	happy5 = GLAD_VALUE_5YEN * (x / GOLD_COIN_5YEN);

	printf("%d", happy500 + happy5);

	return 0;
}

Measured memory_bytes: 128
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

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

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: String -> Bool
solve s = all check sz
    where
        sz = zip s [1..]
        check (c, i) = if even i then
            case c of
                'L' -> True
                'U' -> True
                'D' -> True
                _ -> False
            else
            case c of
                'R' -> True
                'U' -> True
                'D' -> True
                _ -> False
main = do
    tap <- getLine
    putStrLn $ if solve tap then "Yes" else "No"


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

using namespace std;

typedef unsigned long long ull;

ull sum(int x)
{
  return x * (x + 1ULL) / 2ULL;
}

ull lcm(ull a, ull b)
{
  return a / (ull)__gcd(a, b) * b;
}

int main()
{
  ull n, m;
  while (cin >> n >> m, n) {
    vector<ull> p(m);
    for (int i = 0; i < m; i++) {
      cin >> p[i];
    }
    int a = 0, b = 0;
    ull N = n;
    double res = sum(n);
    for (int i = 1; i < (1<<m); i++) {            
      int cnt = 0;
      ull l = 1;
      for (int j = 0; j < m; j++) {
	if (i >> j & 1) {
	  cnt++;
	  l = lcm(l, p[j]);
	}
      }
      if (cnt & 1) {
	N -= n/l;
      } else {
	N += n/l;
      }
      l = l * sum(n / l);
      if (cnt & 1) {	
	res -= l;
      } else {
	res += l;
      }
    }
    if (res == 0) {
      printf("%.10f\n", 0);      
    } else {
      printf("%.10f\n", res/N);
    }
  }
  return 0;
}

Measured memory_bytes: 1228
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic = {}
ans = 0
for  x in a:
    if  x not in dic:
        dic[x] = 1
    else:
        dic[x]+=1
    ans += x

for _ in range(q):
    b,c=map(int,input().split())
    if b not in dic:
        print(ans)
        continue
    ans += (c-b)*dic[b]
    if c not in dic:
        dic[c] = dic[b]
    else:
        dic[c]+=dic[b]
    dic[b]=0
    print(ans)

Measured memory_bytes: 93580
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

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

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next()); // 冷蔵庫種類
        int b = Integer.parseInt(sc.next()); // クーラー種類
        int m = Integer.parseInt(sc.next()); // 割引券枚数
        // 冷蔵庫価格リスト
        ArrayList<Integer> alist = new ArrayList<>(a);
        for (int i = 0; i < a; i++) {
            alist.add(Integer.parseInt(sc.next()));
        }
        // クーラー価格リスト
        ArrayList<Integer> blist = new ArrayList<>(b);
        for (int i = 0; i < b; i++) {
            blist.add(Integer.parseInt(sc.next()));
        }
        // 冷蔵庫最小価格
        int min_a = 999999999;
        for (Integer i : alist) {
            min_a = Math.min(min_a, i);
        }
        // クーラー最小価格
        int min_b = 999999999;
        for (Integer i : blist) {
            min_b = Math.min(min_b, i);
        }
        // 割引反映前の最少額
        int ans = min_a + min_b;
        // 割引反映
        for (int i = 0; i < m; i++) {
            int x = Integer.parseInt(sc.next()); // 割引対象の番号：冷蔵庫
            int y = Integer.parseInt(sc.next()); // 割引対象の番号：クーラー
            int c = Integer.parseInt(sc.next()); // 割引額
            ans = Math.min(ans, alist.get(x - 1) + blist.get(y - 1) - c);
        }

        out.println(ans);
        out.close();
        sc.close();
    }

}


Measured memory_bytes: 65892
s = list(input())

n = len(s)

ans = int(''.join(s[:3]))

for i in range(1,n-2):
    temp = int(''.join(s[i:i+3]))
    # print(temp)
    if abs(753-ans) > abs(753-temp):
        ans = temp

print(abs(753 - ans))

Measured memory_bytes: 3060
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) puts("Yes");
	else puts("No");

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var hw = Reads();
            var h = hw[0];
            var w = hw[1];
            var c = new char[h][];
            for (int i = 0; i < h; i++)
            {
                c[i] = Console.ReadLine().ToArray();
            }
            for (int i = 0; i < 2*h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    Console.Write(c[i / 2][j]);
                }
                Console.WriteLine();
            }
            

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	bool even = true;
	for(int i=0; i<n; i++){
		if(a[i]%2 != 0){
			even = false;
			break;
		}
	}
	if(even){
		cout << "second" << endl;
	}else{
		cout << "first" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define fi first
#define se second
#define vll vector<int>
#define pii pair<int,int>
#define pb push_back
#define sz(v) (int)(v).size()
#define inf 1e18
#define md (int)(1e9+7)
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;

#define M 200010

int p[M],sz[M];
int find(int v){return (v==p[v])?v:p[v]=find(p[v]);}
void join(int a,int b){
	a=find(a),b=find(b);
	if(a==b)return;
	if(sz[a]<sz[b])swap(a,b);
	p[b]=a,sz[a]+=sz[b];
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   	
   	int n;cin>>n;
   	int a[n+1],ida[n+1],b[n+1],idb[n+1];
   	rep(i,0,n){
   		int x,y;cin>>x>>y;
   		a[x]=y,b[y]=x;
   		p[x]=x,sz[x]=1;
   		ida[x]=i+1,idb[y]=i+1;
   	}
   	stack<int>s;
   	rep(i,1,n+1){
   		while(!s.empty() and a[s.top()]>a[i])s.pop();
   		if(!s.empty())join(ida[i],ida[s.top()]);
   		s.push(i);
   	}
   	while(!s.empty())s.pop();
   	for(int i=n;i>=1;--i){
   		while(!s.empty() and a[s.top()]<a[i])s.pop();
   		if(!s.empty())join(ida[i],ida[s.top()]);
   		s.push(i);
   	}
   	while(!s.empty())s.pop();
   	rep(i,1,n+1){
   		while(!s.empty() and b[s.top()]>b[i])s.pop();
   		if(!s.empty())join(idb[i],idb[s.top()]);
   		s.push(i);
   	}
   	while(!s.empty())s.pop();
   	for(int i=n;i>=1;--i){
   		while(!s.empty() and b[s.top()]<b[i])s.pop();
   		if(!s.empty())join(idb[i],idb[s.top()]);
   		s.push(i);
   	}
   	rep(i,1,n+1)cout<<sz[find(i)]<<"\n";
   	
   	
   	
    return 0;
}

Measured memory_bytes: 13016
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        
        double[] p = new double[N];
        
        for(int i = 0; i < N; i++) {
            p[i] = Double.parseDouble(sc.next());
        }
        
        double[][] dp = new double[N+1][N+1]; //コインiまでにj回表
        
        dp[1][0] = 1 - p[0];
        dp[1][1] = p[0];
        
        for(int i = 2; i <= N; i++) {
            for(int j = 0; j <= i; j++) {
                if(j == 0) {
                    dp[i][j] = dp[i-1][j] * (1 - p[i-1]);
                }else if(j < i) {
                    dp[i][j] = dp[i-1][j] * (1 - p[i-1]) + dp[i-1][j-1] * p[i-1];
                }else {
                    dp[i][j] = dp[i-1][j-1] * p[i-1];
                }
            }
        }
        
        double ans = 0;
        for(int j = (N+1) / 2; j <= N; j++) {
            ans += dp[N][j];
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 132404
#include <iostream>

using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (A + B == C + D)
    {
        cout << "Balanced" << endl;
    }
    else if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
from fractions import gcd

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

ans = 'IMPOSSIBLE'

if max(A) < M:
    print(ans)
elif M in A:
    ans = 'POSSIBLE'
    print(ans)
else:
    g = A[-1]
    for a in A:
        g = gcd(g, a)
    if M % g == 0:
        ans = 'POSSIBLE'
        print(ans)
    else:
        print(ans)



Measured memory_bytes: 16056
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

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

Measured memory_bytes: 256
import copy
import itertools

H,W,K = map(int,input().split())
C=[]
Hl=[]
Wl=[]
for h in range(H):
  C.append(list(input()))
  
for i in range(H+1):
  Hl+=list(map(list,itertools.combinations(range(H),i)))
for i in range(W+1):
  Wl+=list(map(list,itertools.combinations(range(W),i)))

def check (D):
  count=0
  for h in range(H):
    for w in range(W):
      if(D[h][w]=="#"):
        count+=1
  return count

def paint (D):
  ans=0
  for hl in Hl:
    for wl in Wl:
      D1 = copy.deepcopy(D)
      count =0
      for h in range(H):
        for w in range(W):
          if(h in hl or w in wl):
            D1[h][w] ="r"
      if(K==check(D1)):
        ans +=1
  return ans

print(paint(C))

Measured memory_bytes: 9144
package main

import (
	"fmt"
)

func SliceUnique(target []uint8) (unique []uint8) {
	m := map[uint8]bool{}

	for _, v := range target {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}

	return unique
}

func main() {
	// Code for D - RGB Triplets
	var n int
	var S string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &S)

	r := 0
	g := 0
	b := 0

	for _, c := range S {
		if c == 'R' {
			r++
		} else if c == 'G' {
			g++
		} else {
			b++
		}
	}

	total := r * g * b
	sub := 0
	for i := 0; i < n; i++ {
		for j:=0; j<(n-i-1);j++ {
			k := j + i + 1
			if (k-i) % 2 != 0{
				continue
			}

			if len(SliceUnique([]uint8{S[i], S[(k+i)/2], S[k]})) == 3 {
				sub += 1
			}
		}
	}
	fmt.Printf("%d", total - sub)
}

Measured memory_bytes: 6468
#include<iostream>

using namespace std;

int main(){
  char e[99];
  cin>>e;
  int fr=e[0]-'0';
  int ba=0,bm=fr;
  for(char *p=e+1;*p;p+=2){
    int nd=p[1]-'0';
    if(*p=='+'){
      fr+=nd;
      ba+=bm;
      bm=nd;
    }else{
      fr*=nd;
      bm*=nd;
    }
  }
  int r;
  cin>>r;
  cout<<"IMLU"[(fr==r)*2+(ba+bm==r)]<<endl;
}

Measured memory_bytes: 1160
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main() {
	int H,W;cin>>H>>W;
	int c1=(W+1)/2,c2=W-c1;
	int d1=(H+1)/2,d2=H-d1;
	if(H==1||W==1){
		cout<<1<<endl;
	}else {
		cout<<c1*d1+c2*d2<<endl;
	}
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

a_sorted = sorted(a, reverse=True)

A_point = 0
B_point = 0

for i in range(0, N):
    if i%2 == 0:
        A_point += a_sorted[i]
    else:
        B_point += a_sorted[i]

print(A_point-B_point)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;



int main(){
    string S; cin >> S;
    deque<char> que(ALL(S));
    ll Q; cin >> Q;
    bool isReversed=false;
    REP(_, Q){
        ll T; cin >> T;
        if(T == 1){
            isReversed = !isReversed;
        }else{ //* T==2
            ll F; cin >> F;
            char C; cin >> C;
            if(isReversed) F = 3-F;
            if(F == 1){
                que.push_front(C);
            }else{ //* F==2
                que.push_back(C);
            }
        }
    }
    if(isReversed) reverse(ALL(que));
    for(auto x:que){
        cout<<x;
    }
    cout<<endl;
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = new String[2];
        try {
            inputs = bufferedReader.readLine().split(" ");
        } catch (IOException e) {
            e.printStackTrace();
        }
        int multi = Integer.parseInt(inputs[0]) * Integer.parseInt(inputs[1]);
        if (multi % 2 == 0) {
            System.out.println("Even");
            return;
        }
        System.out.println("Odd");
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
int a,b,c,max;
  scanf("%d %d %d",&a,&b,&c);
 max=a;
if(max<b)  max=b;
if(max<c)  max=c;
  printf("%d",a+b+c-max);
  
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

     
int main(){
  ll N;

  cin >> N;
  
  int ans[N];
  vector<P> aLst[N];

  queue<ll> que;
  bool start_added = false;
  for(int i = 0; i < N; ++i){
    ll u, v, w;
    cin >> u;
    cin >> v;
    cin >> w;
    P tmp0(v-1, w);
    aLst[u-1].emplace_back(tmp0);
    P tmp1(u-1, w);
    aLst[v-1].emplace_back(tmp1);

    if(!start_added){
      que.push(u);
      start_added = true;
      ans[u] = 0;
    }
  }

#ifdef DEBUG
  cout << N << endl;
#endif

  unordered_map<ll, bool> visited;

  while(!que.empty()){
    ll cur = que.front();
    que.pop();
    //cout << "cur=" << cur << endl;
    for(size_t i = 0; i < aLst[cur].size(); ++i){
      ll cur_child = aLst[cur][i].fs;
      if(visited.count(cur_child) == 0){
	que.push(cur_child);
	visited[cur_child] = true;
	if( aLst[cur][i].sc % 2 == 0){
	  ans[cur_child] = ans[cur];
	} else {
	  ans[cur_child] = 1 - ans[cur];
	}
      }
    }
  }

  for(int i = 0; i < N; ++i){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 12324
n = int(input())
a = list(map(int, input().split()))

b = [a[n-i-1] for i in range(n)]

ans=0
anss=[]
for i in range(n-1):
    if(b[i]<=b[i+1]):
        ans+=1
    else:
        anss.append(ans)
        ans=0
anss.append(ans)
print(max(anss))

Measured memory_bytes: 64356
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
temp = 500000
for i in range(n):
    c = t - (h[i] * 0.006)
    if abs(c - a) < temp:
        temp = abs(c - a)
        ans = i

print(ans + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string S;
    cin >> n;
    cin >> S;
    int mx = 0;
    int cnt;
    bool left, right;
    for (int i=1; i<n;i++){
        cnt = 0;
        for (char c='a';c<='z';c++){
            left = false;
            right = false;
			for(int j=0;j<i;j++)
				if(S[j]==c)
					left=true;
			for(int j=i;j<n;j++)
				if(S[j]==c)
					right=true;
            if (left&&right){
                cnt++;
            }
        }

        mx = max(mx,cnt);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 998244353LL;

ll dp[3300][3300];

int main() {
  ll n, s;
  cin >> n >> s;
  vll a(n);
  rep(i,n) cin >> a[i];
  dp[0][0] = 1;
  for(int i = 1; i<=n; i++) {
    for(int j = 0; j<=s; j++) {
      dp[i][j] = dp[i-1][j]*2;
      if(j-a[i-1]>=0) dp[i][j] += dp[i-1][j-a[i-1]];
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}

Measured memory_bytes: 80992
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 1000000006;

int main()
{
    int n;
    cin >> n;
    ll a[200005];
    ll s = 0;
    ll l = INF;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
        l = min(l, a[i]);
    }
    if(n % 2){
        if(s % 2){
            cout << "First" << endl;
        }
        else{
            cout << "Second" << endl;
        }
    }
    else{
        if(l % 2){
            cout << "First" << endl;
        }
        else{
            if(s % 2){
                cout << "First" << endl;
            }
            else{
                cout << "Second" << endl;
            }
        }
    }
}


Measured memory_bytes: 4664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main(){
		  var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		  int a = b[0];
		  int c = b[1];
		  int d = b[2];
		  int e = b[3];
		    var f= Console.ReadLine().Split().Select(int.Parse).ToArray();
		  int g = f[0];
		  int h = f[1];
		  int i = f[2];
		  int j = f[3];
		  if(a+c+d+e>=g+h+i+j)
		  Console.WriteLine(a+c+d+e);
		  if(a+c+d+e<g+h+i+j)
		  Console.WriteLine(g+h+i+j);
		  }}}
      
      

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll payback = n/15;
    
    cout << (800*n)-payback*200 << endl;
    
    return 0;
}



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

using namespace std;

int main() {

   string color1,color2;
   int no1,no2;
   string color;
   cin>>color1>>color2>>no1>>no2>>color;
   if(color==color1){
       cout<<--no1<<" "<<no2<<endl;
   }
   else cout<<no1<<" "<<--no2<<endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		int d = max(0, a[i - 1] - a[i]);
		ans += d;
		a[i] += d;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4044
from collections import Counter
MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)
ans = 1
if N%2 == 1:
    if C[0] != 1:
        print(0)
        exit(0)
    else:
        for e in C:
            if e == 0:
                pass
            elif C[e] != 2:
                print(0)
                exit(0)
            else:
                ans *= 2
                ans %= MOD
else:
    for e in C:
        if C[e] != 2:
            print(0)
            exit(0)
        else:
            ans *= 2
            ans %= MOD

print(ans)


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



public class Main{

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);
        String chithanh = br.readLine();

        String[] chi = chithanh.split(" ");
        int chinm[] = new int[chi.length];
        int tmp;

        for (int i = 0; i < chi.length; i++)
        	chinm[i] = Integer.parseInt(chi[i]);



        for (int j = chinm.length; j > 1; j--) {
        	for (int k = 0; k < j-1; k++) {
        		if (chinm[k] > chinm[k+1]) {
        			tmp = chinm[k];
        			chinm[k] = chinm[k+1];
        			chinm[k+1] = tmp;
        		}
        	}
        }

        for (int l = 0; l < chinm.length; l++) {
        	System.out.print(chinm[l]);
        	if (l != chinm.length-1)
        		System.out.print(" ");
        	else
        		System.out.print("\n");
        }

	}
}

Measured memory_bytes: 24284