akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;
string L;
int dp[100010][2];

void _main() {
    cin >> L;
    dp[0][0] = 1;
    REP (i, L.size()) {
        if (L[i] == '0') {
            (dp[i + 1][0] += dp[i][0]) %= MOD;
            (dp[i + 1][1] += 3 * dp[i][1]) %= MOD;
        } else {
            (dp[i + 1][0] += 2 * dp[i][0]) %= MOD;
            (dp[i + 1][1] += dp[i][0] + 3 * dp[i][1]) %= MOD;
        }
    }
    cout << (dp[L.size()][0] + dp[L.size()][1]) % MOD << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 2000
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    n=length(s)
    k=parseInt(readline())
    ans=""
    res=Dict{Char,Int}()
    for i in 'a':'z'
        push!(res,i=>'z'-i+1)
    end
    res['a']=0
    for i in 1:n
        if res[s[i]]<=k
            k-=res[s[i]]
            tmp='a'
        else
            tmp=s[i]
        end
        if i==n
            k%=26
            for i in 1:k
                tmp+=1
                if tmp>'z'
                    tmp='a'
                end
            end
            println(tmp)
        else
            print(tmp)
        end
    end
end
main()

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

int main() {
 int disp=1;
 int N,K;
 cin>>N>>K;
 for(int i=0; N>i; i++){
   if(disp<K){
     disp=disp*2;
   }
 else{
     disp=disp+K;
   }
}
 cout<<disp<<endl;
}  






Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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;
}

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int main() {
	int n;
	string s;
	cin >> n >> s;
	rep(i, s.size()) {
		rep(j, n) {
			if (s[i] == 'Z') s[i] = 'A';
			else s[i] += 1;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt(), b = sc.nextInt();
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 24020
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;

namespace AtCoderSolve
{
    class Solve
    {

        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static int N;
        static double[] p;
        
        //static long[] A, B;


        public static void Input()
        {
            var cin = new Scanner();
            N = int.Parse(Console.ReadLine());
            p = Console.ReadLine().Split().Select(double.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            double[,] dp = new double[N + 1, N + 1];
            dp[0, 0] = 1;
            for(var i = 1; i <= N; i++)
            {
                for(var j = 0; j <= i; j++)
                {
                    if (j == 0)
                    {
                        dp[i, j] = dp[i - 1, 0] * (1 - p[i - 1]);
                    }
                    else if (j == i) 
                    {
                        dp[i, j] = dp[i - 1, j - 1] * p[i - 1];
                    }
                    else
                    {
                        dp[i, j] = dp[i - 1, j - 1] * p[i - 1] + dp[i - 1, j] * (1 - p[i - 1]);
                    }
                }
            }

            double ans = 0;
            for(var i = 0; i <= N; i++)
            {
                if (i > N - i)
                {
                    ans += dp[N, i];
                }
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
}






Measured memory_bytes: 80992
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define inv(i, a, b)        for (int i = (int)(a); i >= (int)(b); i--)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, unsigned int y) {                                                    //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class DMenagerie {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    string S;
    cin >> N >> S;
    rep(i, bpm(2, 2)) {
      vector<int> check(N + 2, 0);
      rep(j, 2) {
        if ((i >> j) & 1) {
          check[j + 1] = 1;
        } else {
          check[j + 1] = -1;
        }
      }
      if (check[1] == 1) {
        if (S[0] == 'o') {
          check[0] = check[2];
        } else {
          check[0] = check[2] * -1;
        }
      } else {
        if (S[0] == 'o') {
          check[0] = check[2] * -1;
        } else {
          check[0] = check[2];
        }
      }
      FOR(j, 1, N) {
        if (check[j + 1] == 1) {
          if (S[j] == 'o') {
            check[j + 2] = check[j];
          } else {
            check[j + 2] = check[j] * -1;
          }
        } else {
          if (S[j] == 'o') {
            check[j + 2] = check[j] * -1;
          } else {
            check[j + 2] = check[j];
          }
        }
      }
      if (!(check[0] == check[N] and check[1] == check[N + 1])) goto label;
      rep(j, N) {
        if (check[j + 1] == 1) {
          cout << "S";
        } else {
          cout << "W";
        }
      }
      cout << endl;
      return;
    label:;
    }
    cout << -1 << endl;
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  DMenagerie solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;

string s;
bool g(char c)
{
    return c=='R';
}
int dfl[100005], pop[100005];
int main()
{
    cin >> s;
    fill(dfl, dfl+s.length(), -1);
    for(int i = 0; i < s.length(); i++)
    {
        if((g(s[i]) && !g(s[i+1])) || (!g(s[i]) && g(s[i-1])))
            dfl[i] = 0;
        else if(!g(s[i])) dfl[i] = dfl[i-1] + 1;
    }
    for(int i = s.length() - 1; i >= 0; i--)
    {
        if(dfl[i] == -1 && g(s[i])) dfl[i] = dfl[i+1] + 1;
    }
    for(int i = 0; i < s.length(); i++)
    {
        int fact = g(s[i]) ? 1 : -1;
        pop[i + fact*(dfl[i] + dfl[i]%2)]++;
    }
    for(int i = 0; i < s.length(); i++) cout << pop[i] << " ";
}

Measured memory_bytes: 1536
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


K,S = MI()

ans = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S-(i+j) <= K:
            ans += 1

print(ans)


Measured memory_bytes: 66988
#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
  int a, b, N;
  cin >> N >> a >> b;
  int max = a;
  if (max > b)
    max = b;
  int min = 0;
  if (N - a - b < 0)
    min = abs(N - a - b);
  cout << max << " " << min;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
if p==q:
  print(0)
  exit()
op=[i for i in range(1,n+1)]
oq=op[:]
r=[5040,720,120,24,6,2,1][8-n:]
a,b=1,1
for i in range(n-1):
  a+=op.index(p[i])*r[i]
  b+=oq.index(q[i])*r[i]
  op.remove(p[i])
  oq.remove(q[i])
print(abs(a-b))

Measured memory_bytes: 3064
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
    for j in reversed(range(w)):
        if S[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
for j in range(w):
    for i in range(h):
        if S[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1
    for i in reversed(range(h)):
        if S[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print(ans)


Measured memory_bytes: 309512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] desire = new int[m][2];
    for(int i = 0; i < m; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      desire[i][0] = a;
      desire[i][1] = b;
    }
    Arrays.sort(desire, new Comparator<int[]>() {
      @Override
      public int compare(int[] o1, int[] o2) {
        return o1[1] - o2[1];
      }
    });
    int ans = 0;
    int p = -1;
    for(int i = 0; i < m; i++) {
      if(p < desire[i][0]) {
        ans++;
        p = desire[i][1] - 1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 93212
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
void work()
{
	if(n&1)
	{
		int k1=(n+1)/2;
		int i,j;
		for(i=k1,j=2*n;j<k1+2*n;++i,++j)printf("%d %d %d\n",i-k1+k,j-k1+k,i+j-k1+k);
		for(j=2*n+k1+1-i;i+j<k1+3*n;++i,++j)printf("%d %d %d\n",i-k1+k,j-k1+k,i+j-k1+k);
	}
	else
	{
		int k1=(n+1)/2;
		int i,j;
		for(i=k1,j=2*n;j<k1+2*n;++i,++j)printf("%d %d %d\n",i-k1+k,j-k1+k,i+j-k1+k);
		for(j=2*n+k1+1-i;i+j<k1+3*n-2;++i,++j)printf("%d %d %d\n",i-k1+k,j-k1+k,i+j-k1+k);
		printf("%d %d %d\n",i-k1+k,i+1-k1+k,i+j-k1+k);
	}
}
int main()
{
	scanf("%d %d",&n,&k);
	if(2*k<=n+1)work();
	else printf("-1");
	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n, A[102], cnt = 0;
int main()
{
	cin >> n;
	loop(i, 1, n+1)
	{
		cin >> A[i];
		if ((1 & i) and (1 & A[i]))cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    string s;
    cin >> s;

    sort(s.begin(), s.end());

    bool f = s[0] == s[1] && s[0] != s[2] && s[2] == s[3];

    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int s, w;
	cin >> s >> w;
	if (s <= w)	cout << "unsafe" << endl;
	else {
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
array=[]
while gets
    array=$_.chomp.split(nil).map(&:to_i)
    time=Time.mktime(array[0],array[1],array[2])
      case
        when time<Time.mktime(1868,9,8)
            puts "pre-meiji"
        when time<Time.mktime(1912,7,30)
            puts"meiji #{array[0]-1868+1} #{array[1]} #{array[2]}"
        when time<Time.mktime(1926,12,25)
            puts"taisho #{array[0]-1912+1} #{array[1]} #{array[2]}"
        when time<Time.mktime(1989,1,8)
            puts"showa #{array[0]-1926+1} #{array[1]} #{array[2]}"
        else
            puts"heisei #{array[0]-1989+1} #{array[1]} #{array[2]}"
    end
end

Measured memory_bytes: 6120
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
#define inf 20021225
#define N 100010
using namespace std;

int a[N]; int n; int pre[N],suf[N];
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
void solve()
{
	for(int i=1;i<=n;i++)
	{
		if(i==1)	pre[i]=a[i];
		else	pre[i]=gcd(pre[i-1],a[i]);
	}
	
	for(int i=n;i;i--)
	{
		if(i==n)	suf[i]=a[i];
		else	suf[i]=gcd(suf[i+1],a[i]);
	}
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(i==1)	ans=max(ans,suf[2]);
		else if(i==n)	ans=max(ans,pre[n-1]);
		else	ans=max(ans,gcd(pre[i-1],suf[i+1]));
	}
	printf("%d\n",ans);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	solve();
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int X,Y;
  cin>>X>>Y;
  if(X%Y==0) cout<<-1;
  else cout<<X;
return 0;}


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

bool ableBreak(vector<int> brick) {
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n); 
  rep (i, n) cin >> a.at(i);

  int num = 0;
  rep (i, a.size()) {
    if (a.at(i) == num + 1) num++;
  }

  int ans;
  if (num == 0) {
    ans = -1;
  } else {
    ans = n - num;
  }
  cout << ans << endl;
  return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, D, Q;
int d[500010], q[500010];
ll p[500010];
ll ng[500010];

int main() {
	scanf("%d %d", &N, &D);
	rep(i, N) scanf("%d", &d[i]);
	scanf("%d", &Q);

	rep(i, Q) {
		scanf("%d", &q[i]);
		--q[i];
	}

	p[0] = D;
	rep(i, N) p[i+1] = min(p[i], abs(p[i] - d[i]));

	ng[N] = 1;
	for (int i = N-1; i >= 0; --i) {
		ng[i] = (ng[i+1] * 2 <= d[i] ? ng[i+1] : ng[i+1] + d[i]);
	}

	rep(i, Q) {
		puts(ng[q[i]+1] <= p[q[i]] ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 13696
N, M = map(int, input().split())

l = []

for i in range(N):
  l = [int(j) for j in input().split()]
  K = l.pop(0)
  l = set(l)
  if i > 0:
    l = l & pre_l
  pre_l = l
  
print(len(l))


Measured memory_bytes: 2940
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main = do
    argList <- getIntList
    print $ solve argList

solve :: [Integer] -> Integer
solve argList = if aMod > 0 
                then (+) 1 aDiv
                else aDiv
    where
        a1 = head argList
        a2 = last argList
        aDiv = div (a1 + a2) 2
        aMod = mod (a1 + a2) 2

Measured memory_bytes: 380
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
#define int long long

///My functions

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn];
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n >> k ;

    cout << ( n * 500 >= k ? "Yes" : "No" ) ;






    return 0;
}
























Measured memory_bytes: 8448
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int h,w;
ll d[410][410],ans;
string s[410];

bool c(int i,int j){
	if(i>=0&&i<h&&j>=0&&j<w)return true;
	return false;
}

void dfs(int ii,int jj){
	d[ii][jj]=1;
	queue<P>q;
	ll w=0,b=1;
	q.push(P(ii,jj));
	while(!q.empty()){
		P p=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int ni=p.fr+di[i],nj=p.sc+dj[i];
			if(!c(ni,nj))continue;
			if(d[ni][nj])continue;
			if(s[p.fr][p.sc]!=s[ni][nj]){
				if(s[ni][nj]=='.')w++;
				else b++;
				q.push(P(ni,nj));
				d[ni][nj]=1;
			}
		}
	}
	ans+=w*b;
	return;
}

void input(){
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	return;
}

void solve(){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				if(!d[i][j])dfs(i,j);
			}
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//


signed main(){
    CIN(N,K);
    double ans=0;
    RepS(i,1,N){
       double tmp=1.0/N;
       int cur=i;
       while(cur<K){
           tmp/=2;
           cur*=2;
        }
        ans+=tmp;
    }
    printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string.h>
#include<algorithm>
using namespace std;

int w,h;
long long p[100011],q[100011];
long long sq[100011];
long long ans;


int find(long long aim)
{
    int from,to,mid;
    
    from=0;to=h;
    
    while(from!=to)
    {
        mid=(from+to+1)/2;
        
        if(q[mid]<=aim)
        {
            from=mid;
        }
        else
        {
            to=mid-1;
        }
    }
    
    return from;
}

int main()
{
    int i,j,k;
    int xx,yy;
    cin>>w>>h;
    for(i=1;i<=w;i++)
    {
        scanf("%d",&xx);
        p[i]=xx;
    }
    sq[0]=0;
    for(j=1;j<=h;j++)
    {
        scanf("%d",&xx);
        q[j]=xx;
    }
    sort(q+1,q+h+1);
    
    for(j=1;j<=h;j++)
    {
        sq[j]=sq[j-1]+q[j];
    }
    q[0]=0;
    ans=0;
    
    for(i=1;i<=w;i++)
    {
        int pos=find(p[i]);
        
        //cout<<i<<' '<<pos<<endl;
        //cout<<ans<<endl;
        ans+=sq[pos];
        //cout<<ans<<endl;
        ans+=(long long)p[i]*(1ll+h-pos);
        
        //cout<<ans<<endl;
    }
    ans+=sq[h];
    
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 2560
n,b,f[99999];main(a){for(;++a<5e4;)for(b=a;b<5e4;)f[b+=a]+=!f[a];for(;~scanf("%d",&n);n&&printf("%d\n",b))for(b=0,a=1;a++<n/2;a+=a&1)f[a]+f[n-a]||b++;}

Measured memory_bytes: 792
board = [[False]*1000001]*1000001
while True:
    m = int(input())
    if m == 0: break
    star = list(set(tuple(tuple(map(int, input().split())) for i in range(m))))
    sx, sy = star[0]
    
    n = int(input())
    starlist = list(set([tuple(map(int, input().split())) for i in range(n)]))
    for i in range(len(starlist)):
        board[starlist[i][0]][starlist[i][1]] = True
    for i in range(n):
        flag = True
        for j in range(len(star)-1):
            dx = starlist[i][0] + star[j+1][0] - sx
            dy = starlist[i][1] + star[j+1][1] - sy
            if dx < 0 or 1000000 < dx or dy < 0 or 1000000 < dy or board[dx][dy] == False:
                flag = False
                break

        if flag == True:
            print("{} {}".format(starlist[i][0] - sx, starlist[i][1] -sy))
            break
    

Measured memory_bytes: 22696
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll a,b;
    cin>>a>>b;
    rep1(i,10000)
    {
        if(i*2/25==a&&i/10==b)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll S, W;
  cin >> S >> W;
  if(S <= W){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }

  return 0;
}


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

int main(){
  
  int N,M,ans = 0;
  
  cin >> N;
  
  map<string,int> check;

  vector<string> s(N);
  
  for(int i = 0; i < N; ++i){
    cin >> s.at(i);
    ++check[s.at(i)];
  }
  
  cin >> M;
  
  for(int i = 0; i < M; ++i){
    string t;
    cin >> t;
    --check[t];
  }
  
  for(int i = 0; i < N; ++i){
    
    if(ans < check[s.at(i)]){
    
      ans = check[s.at(i)];
    
    }
  
  }
  
  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())


if C*2 > A + B:
    x = 0
    price = A * X + B * Y
else:
    if X <= Y:
        x = X * 2
        a = 0
        b = Y - x // 2
        price = C*x + min(b*B, 2*b*C)
    else:
        x = Y * 2
        a = X - x // 2
        b = 0
        price = C*x + min(a*A, 2*a*C)
print(price)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, k;
    cin >> n >> k;
    int x[n];
    int d = 0;
    rep(i, n)
    {
        cin >> x[i];
        if (x[i] <= 0)
            d = i;
    }

    int l = max(d - k, 0);
    int r = max(d + k, n - 1);
    int ans = 1e9;

    for (int i = l; i <= r; i++)
    {
        if (i + k - 1 >= n)
            break;
        ans = min(abs(x[i + k - 1] - x[i]) + abs(x[i]), min(abs(x[i + k - 1] - x[i]) + abs(x[i + k - 1]), ans));
    }
    OP(ans);

    return 0;
}

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

const int N = 3e5 + 9;

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n; int tot = 0;
	vector<array<int, 3>> a, last; vector<int> ans;
	int cur = 0;
	for (int i = 1; i <= n; i++) {
		string s; cin >> s;
		vector<char> v;
		for (auto x: s) {
			if (x == '(') tot++, v.push_back('(');
			else {
				tot--;
				if (v.size() && v.back() == '(') v.pop_back();
				else v.push_back(')');
			}
		}
		int op = 0, cl = 0;
		for (auto x: v) {
			op += x == '(';
			cl += x == ')';
		}
		if (op && !cl) ans.push_back(i), cur += op;
		else if (cl && !op) last.push_back({cl, 0, i});
		else if (op && cl) a.push_back({op - cl, op, i});
		else ans.push_back(i);
	}
	if (tot != 0) return cout << "No\n", 0;
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for (auto x: a) {
		if (cur < x[1] - x[0]) return cout << "No\n", 0;
		cur += x[0];
		ans.push_back(x[2]);
	}
	for (auto x: last) {
		if (cur < x[0]) return cout << "No\n", 0;
		cur -= x[0];
		ans.push_back(x[2]);
	}
	cout << "Yes\n";
	//for (auto x: ans) cout << x << ' '; cout << '\n';
    return 0;
}

Measured memory_bytes: 16836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T>
inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n ) cin>>v[i];
    int res = v[0];
    repk(i, 1,n){
        res = GCD(res, v[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

#define LL_ABS(x) (((((x) < 0) ? ((x) * (-1)) : (x))))

static void ABC120D_DecayedBridges();
static void ABC119D_LazyFaith();

#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC119D_LazyFaith();

	fflush(stdout);
	return 0;
}
#endif


static int binSearch(const L_LONG& xpoint, const L_LONG* container, int contCount, int & secondIdx)
{
	int startPoint = 0, endPoint = contCount;
	int bsTarget = 0, tmpTarget = 0;
	L_LONG dist = 0, tmpDist = 0;
	while (1) {
		bsTarget = (startPoint + endPoint) / 2;

		if ((endPoint - startPoint) < 2) {
			secondIdx = -1;

			if ((container[bsTarget] < xpoint) && ((bsTarget + 1) < contCount)) {
				secondIdx = bsTarget + 1;
			}
			else if ((container[bsTarget] >= xpoint) && ((bsTarget - 1) >= 0)) {
				secondIdx = bsTarget - 1;
			}
		
			break;
		}
		else if (container[bsTarget] < xpoint) {
			startPoint = bsTarget;
		}
		else if (container[bsTarget] > xpoint) {
			endPoint = bsTarget;
		}
	}
	return bsTarget;
}

static void search(const L_LONG& xpoint, const L_LONG* shrine, int sCount, const L_LONG* temple, int tCount, L_LONG& answer)
{
	int sh1stIdx = 0, sh2ndIdx = 0;
	int tm1stIdx = 0, tm2ndIdx = 0;

	sh1stIdx = binSearch(xpoint, shrine, sCount, sh2ndIdx);
	tm1stIdx = binSearch(xpoint, temple, tCount, tm2ndIdx);

	L_LONG shDist[2] = { 0 };
	L_LONG tmDist[2] = { 0 };

	int shCount = 1;
	shDist[0] = xpoint - shrine[sh1stIdx];
	if (sh2ndIdx >= 0) {
		shCount = 2;
		shDist[1] = xpoint - shrine[sh2ndIdx];
	}
	
	int tmCount = 1;
	tmDist[0] = xpoint - temple[tm1stIdx];
	if (tm2ndIdx >= 0) {
		tmCount = 2;
		tmDist[1] = xpoint - temple[tm2ndIdx];
	}

	L_LONG total = 0;
	L_LONG totalMin = LLONG_MAX;
	for (int s = 0; s < shCount; s++) {
		for (int t = 0; t < tmCount; t++) {
			if (((shDist[s] < 0) && (tmDist[t] < 0)) || ((shDist[s] >= 0) && (tmDist[t] >= 0))) {
				if (LL_ABS(shDist[s]) > LL_ABS(tmDist[t])) {
					total = LL_ABS(shDist[s]);
				}
				else {
					total = LL_ABS(tmDist[t]);
				}
			}
			else if (LL_ABS(shDist[s]) > LL_ABS(tmDist[t])) {
				total = LL_ABS(tmDist[t]) * 2 + LL_ABS(shDist[s]);
			}
			else {
				total = LL_ABS(tmDist[t]) + LL_ABS(shDist[s]) * 2;
			}

			if (totalMin > total) {
				totalMin = total;
			}
		}
	}
	answer = totalMin;
}

static void ABC119D_LazyFaith()
{
	static L_LONG shrine[100000] = { 0 };
	static L_LONG temple[100000] = { 0 };
	static L_LONG xpoint[100000] = { 0 };
	static L_LONG answer[100000] = { 0 };

	int A = 0, B = 0, Q = 0;

	scanf(" %d %d %d", &A, &B, &Q);

	for (int i = 0; i < A; i++) {
		scanf(" %lld", &shrine[i]);
	}
	for (int i = 0; i < B; i++) {
		scanf(" %lld", &temple[i]);
	}
	for (int i = 0; i < Q; i++) {
		scanf(" %lld", &xpoint[i]);
	}

	for (int i = 0; i < Q; i++) {
		search(xpoint[i], shrine, A, temple, B, answer[i]);
		printf("%lld\n", answer[i]);
	}
}



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

int main(){
    int n;
    cin >> n;
    int y;
    cin >> y;
    int a=y/1000;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
                if(i*10+j*5+n-i-j==a){
                    printf("%d %d %d\n",i,j,n-i-j);
                    return 0;
                }
        }
    }
    printf("%d %d %d\n",-1,-1,-1);
    }

Measured memory_bytes: 256
from scipy.misc import comb
 
N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1
 
a = [comb(v, 2, exact=True) for v in s.values()]
print(sum(a))

Measured memory_bytes: 28012
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    string x, y;
    string a, b;

    for (int i = 0; i < 105; i++) {
        a += '0';
        b += '0';
    }

    cin >> x >> y;

    for (int i = 0; i < x.size(); i++) {
        a[a.size() - 1 - i] = x[x.size() - 1 - i];
    }
    for (int i = 0; i < y.size(); i++) {
        b[b.size() - 1 - i] = y[y.size() - 1 - i];
    }

    if (a > b) {
        cout << "GREATER" << endl;
    } else if (a < b) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1e9+7
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

template<class T> void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
template<class T> void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}

template<class T> void read(T& a) {
    std::cin>>a;
}

template<class T> void read(T& a, T& b) {
    std::cin>>a>>b;
}
template<class T> void read(T& a,T& b, T& c) {
    std::cin>>a>>b>>c;
}

template<class T> void read(T& ara, int sidx,  int eidx) {
    for(int i=sidx; i<eidx; i++)
        std::cin>>ara[i];
}




using namespace std;
using namespace __gnu_pbds;

const int maxn=500;
const int inf = INT_MAX;


void solve()
{
	ll d,t,s;
	cin>>d>>t>>s;
	
	
	if((s*t)>=d)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
	
	
	
}



int main()
{
	fast_cin;
	//case
	{
		solve();
		
	}
   
    return 0;
}


Measured memory_bytes: 3660
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  [t, a] <- map (read::String -> Float) . words <$> getLine
  arr <- map (read::String -> Float) . words <$> getLine
  let temps = listArray (1, n) $ map (\x -> t - x * 0.006) arr
  print . snd $ foldl (\(val, index) i -> let diff = abs $ temps ! i - a
    in if diff < val then (diff, i) else (val, index)) (abs (temps ! 1 - a), 1) [2..n]

Measured memory_bytes: 1276
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            
            if(a >= 3200) { Console.WriteLine(s); }
            else { Console.WriteLine("red"); }
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
A, B = map(int, input().split())

n_1 = int(A / n)
n_2 = int(B / n)
nn_1 = A%n
nn_2 = B%n
if n == 1: print('OK')
else:
    if nn_1 ==0 or nn_2 == 0:print('OK')
    elif n_2 != n_1: print('OK')
    else: print('NG')

Measured memory_bytes: 9188
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s;
  cin >> s;
  vector<vector<int>> v(1);
  LL n = s.size();
  REP(i,n) {
    if(s[i]=='A') v.back().push_back(0);
    else if(s[i]=='B') {
      if(i+1<n && s[i+1] == 'C') {
        v.back().push_back(1);
        ++i;
      } else {
        v.push_back(vector<int>());
      }
    }
    else v.push_back(vector<int>());
  }
  LL answer = 0;
  for(auto u:v) {
    LL tmp = 0;
    for(auto i:u) {
      if(i) answer+=tmp;
      else ++tmp;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 6772
#include <stdio.h>


int main() {
	int n,s;
	char m;
	bool S[13] = {};
	bool H[13] = {};
	bool C[13] = {};
	bool D[13] = {};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {

		scanf("%c%c%d", &m, &m, &s);
		if (m == 'S')S[s - 1] = true;
		if (m == 'H')H[s - 1] = true;
		if (m == 'C')C[s - 1] = true;
		if (m == 'D')D[s - 1] = true;

	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++)
		{
			if (i == 0) {
				if (!S[j])printf("S %d\n", j + 1);
			}
			if (i == 1) {
				if (!H[j])printf("H %d\n", j + 1);
			}
			if (i == 2) {
				if (!C[j])printf("C %d\n", j + 1);
			}
			if (i == 3) {
				if (!D[j])printf("D %d\n", j + 1);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int n=t.length(),c=0;
  for(int i=0;i<n;i++)
  { if(s[i]==t[i])
      continue;
    else 
      c++;}
       if((c==0) || (c>1))
         cout<<"No";
       else
         cout<<"Yes";
}


Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n;i++)
typedef long long ll;
using namespace std;

int main(void){
    // Your code here!
    while(true){
        int n,x;
        int ans = 0;
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        for(int a=1;a<=n-2;a++){
            for(int b = a+1;b<=n-1;b++){
                if(x-a-b>b && x-a-b<=n){
                    ans++;
                    /*cout << a << endl;
                    cout << b << endl;*/
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#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<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

int main() {
	int N,K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import defaultdict

setrecursionlimit(10 ** 9)


def input():
    return stdin.readline().strip()


X = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
for i, a in enumerate(A, 1):
    d[-(a + i)] += 1

ans = 0
for i, a in enumerate(A, 1):
    ans += d[a - i]

print(ans)


Measured memory_bytes: 61708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

vector<vector<int>> GetAdjacencyList(int n, int m)
{
	vector<vector<int>> al(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		al[a].push_back(b);
		al[b].push_back(a);
	}
	return al;
}

void DFS(int id, int node, const vector<vector<int>>& al, vector<int>& group)
{
	group[node] = id;
	for (int i = 0; i < al[node].size(); i++) {
		if (group[al[node][i]]) continue;
		group[al[node][i]] = id;
		DFS(id, al[node][i], al, group);
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> al = GetAdjacencyList(n, m);
	vector<int> group(n);
	for (int i = 0; i < n; i++) {
		int id = i + 1;
		if (!group[i]) DFS(id, i, al, group);
	}

	map<int, int> freq;
	for (int i = 0; i < n; i++) freq[group[i]]++;
	int ans = 0;
	for (int i = 0; i < freq.size(); i++) ans = max(ans, freq[i]);
	cout << ans << endl;
}


Measured memory_bytes: 24368
#include <bits/stdc++.h>
#define int long long
//#define C(a, b) D(F[a], (F[a - b] * F[b]) % mod)
//#define D(a, b) (a * P(b, mod - 2)) % mod
using namespace std;

const int mod = 1e9 + 7;

long long P(long long a, long long b) {
	long long d = 1;
	while(b) {
		if(b & 1) d = (d * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return d;
}

int F[100005] = {1};

long long D(long long a, long long b) {
	return (a * P(b, mod - 2)) % mod;
}

long long C(long long a, long long b) {
	return D(F[a], (F[a - b] * F[b]) % mod);
}

int n, k, a[100005];
long long sj, dj, fp;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 1; i < 100005; ++i) F[i] = (F[i - 1] * i) % mod;
	cin >> n >> k;
	if(k == 1) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for(int i = k; i <= n; ++i) {
		fp = (fp + (C(i - 1, k - 1) * a[i]) % mod) % mod;
	}
	for(int i = 1; i <= n - k + 1; ++i) {
		fp = (((fp - (C(n - i, k - 1) * a[i]) % mod) % mod) + mod) % mod;
	}
	cout << fp << endl;
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (h[a] < h[b]) {
            g[a].push_back(b);
        } else if (h[a] > h[b]) {
            g[b].push_back(a);
        } else if (h[a] == h[b]) {
            g[a].push_back(b);
            g[b].push_back(a);
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (g[i].size() == 0) {
            ans++;
        }
    }


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

Measured memory_bytes: 8204
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;

int main() {
    long long int a, b, c, d;
    cin  >> a >> b >> c >> d;

    long long int max = a * c;
    if (max < a * d) {
    	max = a * d;
    }
    if (max < b * c) {
    	max = b * c;
    }
    if (max < b * d) {
    	max = b * d;
    }
    cout << max << endl;

    return 0;
}


Measured memory_bytes: 3568