akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;  
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int MAXN = 5001;
const int mod = 1e9 + 7;

int n;
string s;
int dp[MAXN][MAXN];

void add(int& a, int b) {
    b %= mod;
    a += b;
    if (a >= mod) a -= mod;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> s;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            if (j < n) {
                add(dp[i + 1][j + 1], dp[i][j]);
            }
            if (j == 0) {
                add(dp[i + 1][0], dp[i][0]);
            } else {
                add(dp[i + 1][j - 1], 2ll * dp[i][j]);
            }
        }
    }
    cout << dp[n][s.size()];
}
/*

*/

Measured memory_bytes: 199012
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    ll n;
    cin >> n;
    vector<ll> r;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            r.push_back(i);
            r.push_back(n / i);
        }
    }
    SORT(r);
    int a = 0, b = 0;
    while (r[r.size() / 2 ]) {
        a++;
        r[r.size() / 2 ] /= 10;
    }
    while (r[r.size() / 2 -1]) {
        b++;
        r[r.size() / 2 -1] /= 10;
    }
    cout << max(a, b) << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [] * N
xy = []
for _ in range(N):
    A.append(int(input()))
    xy.append([list(map(int, input().split())) for _ in range(A[-1]) ])

S = 0
for bit in range(2 ** N):
    s = 0
    T = True
    for i in range(N):
        if not T:
            break
        if (bit & (1 << i)):
            s += 1
            for x, y in xy[i]:
                x -= 1
                if y == 1 and (not (bit & (1 << x))):
                    T = False
                    break
                if y == 0 and (bit & (1 << x)):
                    T = False
                    break
    if T:
        S = max(S, s)

print(S)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n,sum=0;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	vector<int>c(n-1);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n-1; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		sum += b[i];
		//cout << "cc" << endl;
	}
	for (int i = 1; i < n; i++) {
		//cout << "aaa" << endl;
		if (a[i-1]+1==a[i] ) {
			sum += c[(a[i-1])-1];
			//cout << "aa" << endl;
		}
		
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
typedef long long ll;
const int M=1e6+6;
int a[M];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>k>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=k-a[n-1]+a[0];
    //cout<<ans<<endl;
    for(int i=1;i<n;i++)
        ans=max(ans,a[i]-a[i-1]);
    cout<<k-ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a, b, c, n, temp;
		Boolean is_changed = true;
		n = in.nextInt();
		for (int i = 0; i < n; i++) {
			a = in.nextInt();
			b = in.nextInt();
			c = in.nextInt();
			while (is_changed == true) {
				is_changed = false;
				if (a > b) {
					temp = a;
					a = b;
					b = temp;
					is_changed = true;
				}
				if (b > c) {
					temp = b;
					b = c;
					c = temp;
					is_changed = true;
				}
			}
			if (a * a + b * b - c * c == 0) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
			is_changed = true;
		}
	}
}

Measured memory_bytes: 32784
n, m = map(int, input().split())
store = []
for _ in range(m):
    a, b = map(int, input().split())
    store.append([a, b])
store.sort(key = lambda x:x[0])
count = 0
ans = 0
while count < m:
    index = 1
    t = store[0][1]
    while index < len(store) and store[index][0] < t:
        t = min(t, store[index][1])
        index += 1
    count += index
    store = store[index:]
    ans += 1
print(ans)

Measured memory_bytes: 22384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
if (n%2).zero?
  puts n/2
else
  puts n/2+1
end

Measured memory_bytes: 1788
#include <cstdio>

using namespace std;

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    int c1,c2,c3,c4,n;
    scanf("%d%d%d%d",&c1,&c2,&c3,&c4);
    scanf("%d",&n);
    if(c1*2<c2) c2=c1*2;
    if(c2*2<c3) c3=c2*2;
    if(c3*2<c4) c4=c3*2;
    long long sol=1LL*(n/2)*c4;
    if(n%2==1) sol=sol+c3;
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int p[111111]={};
void Furui(){
  for(int i=2;i<334;i++){
    if(p[i]==1){
      for(int j=i*2;j<111111;j+=i)p[j]=0;
    }
  }
}
int main(){
  for(int i=2;i<111111;i++)p[i]=1;
  Furui();
  int q;
  scanf("%d",&q);
  int x[111111]={};
  for(int i=2;i<55555;i++){
    if(p[i]==1){
      if(p[2*i-1]==1){
        x[2*i-1]=1;
      }
    }
  }
  for(int i=1;i<111111;i++)x[i]+=x[i-1];
  for(int i=0;i<q;i++){
    int l,r;
    scanf("%d%d",&l,&r);
    printf("%d\n",x[r]-x[l-1]);
  }
  return 0;
}

Measured memory_bytes: 1408
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = new string(Console.ReadLine().Reverse().ToArray());

            var devides = new[] { "dream", "dreamer", "erase", "eraser" }
                .Select(d => new string(d.Reverse().ToArray()))
                .ToArray();

            var maxDevideLength = devides.Select(d => d.Length).Max();

            var startIndex = 0;
            for (var endIndex = 1; endIndex <= S.Length; endIndex++)
            {
                var length = endIndex - startIndex;
                if (length > maxDevideLength)
                {
                    break;
                }

                var sub = S.Substring(startIndex, length);
                var devide = devides.FirstOrDefault(d => d == sub);
                if (devide != null)
                {
                    startIndex = endIndex;
                }
            }

            Console.WriteLine(startIndex == S.Length ? "YES" : "NO");
        }
    }
}


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



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BShiritori {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vector<string> W(n);
        in >> W;
        set<string> S(all(W));
        bool res = sz(S) == n;
        FOR(i, 1, n) {
            if (W[i][0] != W[i - 1].back()) {
                res = false;
            }
        }
        out << (res ? "Yes" : "No") << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BShiritori solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,ans1,ans2;
	cin>>a>>b>>c;
	ans1=b-a;
	ans2=c-b;
	if(ans1==ans2) cout<<"YES"<<"\n";
	else cout<<"NO"<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
  int A, B, C, X, n, count = 0;
  cin >> A >> B >> C >> X;

  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if(500 * i + 100 * j + 50 * k == X) count++;
      }
    }
  }
  cout << count << endl;
}

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

const ll INF = 1LL << 60;

ll n, k;

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

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

    // k を移動人数とする
    k = min(k, n - 1);
    combination comb(2e5 + 10);

    mint ans = 0;
    for (int i = 0; i <= k; i++) {
        // 移動する人の組み合わせ x 移動先 (重複組合せ)
        ans += comb(n, i) * comb(n - i + i - 1, i); 
    }
    cout << ans << endl;
}

Measured memory_bytes: 6364
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;
const int M=1e3+7;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int n,s[M],ans=1e9,sum;
int main(){
	n=read();
	for(int i=1;i<=n;i++) s[i]=read();
	for(int x=-100;x<=200;x++){
		sum=0;
		for(int i=1;i<=n;i++) sum=sum+(s[i]-x)*(s[i]-x);
		if(sum<ans) ans=sum;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = [input() for _ in range(N)]

word = {}
for i in range(N):
    if L[i] in word:
        word[L[i]] += 1
    else:
        word[L[i]] = 1

max_count = 0
for i in range(N):
    max_count = max(max_count, word[L[i]])
    
ans = []
for i in range(N):
    if word[L[i]] == max_count:
        ans.append(L[i])
  
ans = list(set(ans))
ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45456
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
const int MAXVAL=100001;
LL dp[MAXVAL+5];
int main(){
	rb(i,1,MAXVAL) dp[i]=9000000000;dp[0]=0;
	LL n,w;
	scanf("%I64d %I64d",&n,&w);
	rb(i,1,n){
		int a,b;
		scanf("%d %d",&a,&b);
		rl(j,MAXVAL,b){
			dp[j]=min(dp[j],dp[j-b]+a);
		}
	}
	int final;
	rb(i,0,MAXVAL){
		if(dp[i]<=w){
			final=i;
		}
	}
	printf("%d\n",final);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int a[20000];
int main()
{
  long long int n,i,j,k,ans;
  cin>>n;
  for(i=0;i<n;i++)cin>>a[i];
  ans=0;
  sort(a,a+n);
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      for(k=j+1;k<n;k++)
      {
        if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k] && (a[i]+a[j])>a[k]) ans++;
      }
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define int long long int
using namespace std;
int inv(int a, int m=modulo)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      //freopen("q.gir","r",stdin);
      int A,B;
      cin>>A>>B;
      int D=A+B;
      if(D%3)cout<<0;
      else{
            int R=D/3;
            B-=R;
            if(B<0){
                  cout<<0;
                  return 0;
            }
            if(B>R){
                  cout<<0;
                  return 0;
            }
            int mult[1000002];
            mult[0]=1;
            for(int i=1;i<=R;i++)mult[i]=mult[i-1]*i%modulo;
            cout<<mult[R]*inv(mult[B])%modulo*inv(mult[R-B])%modulo;

      }
}


Measured memory_bytes: 7424
S=input()
T=input()
ls =len(S)
lt=len(T)
maxn=0
for i in range(ls-lt+1):
  tmp=0
  for j in range(lt):
    if T[j]==S[i+j]:
      tmp+=1
  if tmp >maxn:
    maxn=tmp
print(lt-maxn)

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

int main(){
	int n;cin>>n;
  	long long a[n];for(int i=0;i<n;i++)cin>>a[i];
  	long long ans=0;
  	for(int i=1;i<n;i++){
    	if(a[i]<a[i-1])ans+=a[i-1]-a[i];
      	a[i]=max(a[i],a[i-1]);
    }
  	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100];
    char c[100],v[100];
    cin>>c>>s>>v;
    if(c[0]>='a' && c[0]<='z')
    c[0]-=32;
    if(s[0]>='a' && s[0]<='z')
    s[0]-=32;
    if(v[0]>='a' && v[0]<='z')
    v[0]-=32;
    cout<<c[0]<<s[0]<<v[0];
    
    return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int N;

    cin >> N;

    char S;
    REP(i,N){
        cin >> S;
        if(S=='Y'){
            cout << "Four";
            break;
        }else if(i==N-1){
            cout << "Three";
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <iterator>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
	
	int const N_MAX = 1000;
	int const W_MAX = 10000;

	int n = 0;
	cin >> n;

	vector<int> W, S, T;
	vector<bool> C;
	
	W.resize(n, 0);     // idx -> W
	S.resize(n, 0);     // sorted Wi
	T.resize(W_MAX, 0); // W -> idx
	C.resize(n, false); // flag for searched or not

	int g_min = W_MAX; // global_min of Wi
	for (int i = 0; i < n; i++) {
		cin >> W[i];
		g_min = (W[i] < g_min) ? W[i] : g_min;
	}

	for (int i = 0; i < n; i++) {
		T[W[i]] = i;
	}

	S = W;
	stable_sort(S.begin(), S.end());

	int score = 0;

	//cout << "<<W>> ";
	//trace(W);
	//cout << "<<S>> ";
	//trace(S);

	for (int i = 0; i < n; i++) {
		if (!C[T[S[i]]]) {
			int l_min = W_MAX;
			int sum = 0;
			int cnt = 0;
			//vector<int> L;
			for(int j = S[i]; !C[T[j]]; j = S[T[j]] ) {
				//L.push_back(j);
				C[T[j]] = true;
				cnt++;
				sum += j;
				l_min = (j < l_min) ? j : l_min;
			}
			//cout << endl;
			//cout << "<<L>> ";
			//trace(L);
			//cout << "sum:" << sum << " N:" << cnt << " l_min:" << l_min << " g_min" << g_min << endl;
			//cout << sum + l_min*(cnt - 2) << " or " << sum + g_min*(cnt + 1) + l_min << endl;
			score += min(sum + l_min*(cnt - 2), sum+g_min*(cnt+1)+l_min);
			//cout << "Now, Cost is " << score << endl;
			//L.clear();
		}
	}

	cout << score << endl;

	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      if(n%2)cout<<0;
      else{
      	ll x=5,ans=0;
      	while(x*2<=n){
      		ans+=(n/(x*2));
      		x*=5;
      	}
      	cout<<ans;
      }
}

Measured memory_bytes: 3584
n,x=map(int,input().split())

if n==2 and x==2:
  print("Yes",*[1,2,3],sep="\n")
elif x==1 or x>=2*n-1:
  print("No")
else:
  print("Yes")
  if x==2:
    t=[4,2,1,3]
  else:
    t=[x-1,x+1,x,x-2]
  p=[i for i in range(1,2*n) if i not in t]
  print(*p[:n-3]+t+p[n-3:],sep="\n")

Measured memory_bytes: 15656
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint a,b;
	cin>>a>>b;
	if(a*b<=0){
		cout<<"Zero"<<"\n";
	}else if(a<0&&b<0){
		cout<<((abs(a-b)+1)%2?"Negative":"Positive")<<"\n";
	}else{
		cout<<"Positive"<<"\n";
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/prime_sieve.hpp
#ifndef PRIME_SIEVE_HPP
#define PRIME_SIEVE_HPP


/*
// primes are all primes less than or equal to 100
std::vector<std::int_fast64_t> primes = tools::prime_sieve<std::int_fast64_t>(100);
*/

namespace tools {
  template <typename T>
  std::vector<T> prime_sieve(const T n) {
    std::vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;

    const T max = static_cast<T>(std::sqrt(n));
    for (T i = 2; i <= max; ++i) {
      if (is_prime[i]) {
        for (T j = i * 2; j <= n; j += i) {
          is_prime[j] = false;
        }
      }
    }

    std::vector<T> result;
    for (T i = 0; i <= n; ++i) {
      if (is_prime[i]) {
        result.push_back(i);
      }
    }
    return result;
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  const std::vector<i64> primes = tools::prime_sieve<i64>(55555);

  std::vector<i64> answers;
  answers.reserve(N);
  for (const i64& prime : primes) {
    if (static_cast<i64>(answers.size()) >= N) break;
    if (prime % 5 == 1) {
      answers.push_back(prime);
    }
  }

  std::string delimiter = "";
  for (const i64& answer : answers) {
    std::cout << delimiter << answer;
    delimiter = " ";
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] x = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            // System.out.printf("x[%d] = %d %n", i, x[i]);
            ans += x[i] / 2;
            if (x[i] % 2 != 0) {
                if (i + 1 >= n) {
                    break;
                }
                if (x[i + 1] <= 0) {
                    continue;
                }
                ans++;
                x[i + 1]--;
            }
            // System.out.println("i = " + i);
            // System.out.println("ans = " + ans);
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22200
import itertools
N=int(input())
A=[]
arr=[]
ans=0
li=list(itertools.product([0,1], repeat=N))

for n in range(N):
  a=int(input())
  A.append(a)
  arr.append([ list(map(int,input().split())) for  _ in range(a)])
  
for l in li:
  
  flg=0
  for n in range(N):
    if l[n]==1:
      for m in range(A[n]):
        if l[arr[n][m][0]-1]!=arr[n][m][1]:
          flg=1
          break
      if flg==1:
        break
  if flg==1:
    continue
  count=l.count(1) 
  ans=max(ans,count)
      
print(ans)      
      
      

Measured memory_bytes: 8820
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
a = inpl()
sum_a = sum(a)
a_2 = [i*2 for i in a]
ans = [0] * n

ans[0] = sum_a - sum(a_2[1::2])
for i in range(n-1):
    ans[i+1] = a_2[i] - ans[i]
print(*ans)

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

vector<int>vec[100005];

int va[100005];
int sh[100005];

signed main() {
	int n, u, v;
	cin >> n >> u >> v;
	u--, v--;
	int a[100005], b[100005];
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
	}
	rep(i, n)va[i] = -1;
	queue<int>que;
	que.push(v);
	va[v] = 0;
	while (!que.empty()) {
		int now = que.front();
		que.pop();
		rep(i, vec[now].size()) {
			if (va[vec[now][i]] == -1) {
				que.push(vec[now][i]);
				va[vec[now][i]] = va[now] + 1;
			}
		}
	}
	rep(i, n) sh[i] = -1;
	que.push(u);
	sh[u] = 0;
	while (!que.empty()) {
		int now = que.front();
		que.pop();
		rep(i, vec[now].size()) {
			if (sh[vec[now][i]] == -1) {
				que.push(vec[now][i]);
				sh[vec[now][i]] = sh[now] + 1;
			}
		}
	}
	int ans = 0;
	rep(i, n) {
		if (sh[i] <= va[i]) {
			ans = max(ans, va[i] - 1);
		}
	}
	/*rep(i, n) {
		cout << va[i] << " ";
	}
	cout << endl;
	rep(i, n) {
		cout << sh[i] << " ";
	}
	cout << endl;*/
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int arr[] = new int[N+1];
    int srt[] = new int[N+1];
    for(int i = 1; i<=N; i++){
      arr[i] = sc.nextInt();
      srt[i] = arr[i];
    }
    Arrays.sort(srt);
    for(int i = 1; i<=N; i++){
      if(arr[i] >= srt[N/2+1]){
        System.out.println(srt[N/2]); 
      }
      else{
        System.out.println(srt[N/2+1]); 
      }
    }
  }

}


/*

pre[i] = arr[1] + arr[2] + arr[3] + arr[4] + ... + arr[i]
The question for some l and r
arr[l] + arr[l+1] + arr[l+2] + ... + arr[r]
= 
pre[r] - pre[l-1]

pre[r]   = arr[1] + arr[2] + ... + arr[l-1] + arr[l] + arr[l+1] + ... + arr[r]
-
pre[l-1] = arr[1] + arr[2] + ... + arr[l-1]

*/


Measured memory_bytes: 88088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    int minnum = INF;
    int maxnum = 0;
    for(int i = 0; i<n; i++){
        int num; cin >> num;
        minnum = min(minnum,num);
        maxnum = max(maxnum,num);
    }
    cout << maxnum - minnum << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

class Prefecture():
    def __init__(self, i, P, Y):
        self.i = i
        self.P = P
        self.Y = Y
    
    def make_id(self, x):
        upper = str(self.P)
        while len(upper) < 6:
            upper = "0" + upper
        lower = str(x)
        while len(lower) < 6:
            lower = "0" + lower
        self.id = upper + lower            


def solve():
    N, M = list(map(int, input().split(" ")))
    prefectures = [None for i in range((N+1))]
    for i in range(M):
        p, y = list(map(int, input().split(" ")))
        if prefectures[p] is None:
            prefectures[p] = []
            prefectures[p].append(Prefecture(i, p, y))
        else:
            prefectures[p].append(Prefecture(i, p, y))

    # ID作成
    ans = []
    for i in range(1, N+1):
        if prefectures[i] is None:
            continue

        prefectures[i].sort(key=lambda x: x.Y)
        for j in range(len(prefectures[i])):
            prefectures[i][j].make_id(j+1)
            ans.append(prefectures[i][j])
    
    # iでソートして出力
    ans.sort(key=lambda x: x.i)

    for prefecture in ans:
        print(prefecture.id)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 92956
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int a, b, c;

signed main()
{
    cin >> a >> b >> c;

    if (b / a < c){
        cout << b/a << endl;
    } else {
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

int n, k, r, s, p;
string t;

int get_score(char c){
    if(c == 'r')    return p;
    else if(c == 's')   return r;
    else    return s;
}

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

    cin >> n >> k >> r >> s >> p >> t;

    ll res = 0;
    for(int i = 0; i < k; ++i){
        bool flag = false;
        for(int j = i; j < n; j += k){
            if(flag){
                flag = false;
            }
            else{
                res += get_score(t[j]);
                if(t[j] == t[j+k]){
                    flag = true;
                }
                
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define rep(i,n) for(int i=1;i<=n;i++)
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  998244353 ;

int n, m, ans;
int a, b, c, d;

map<string, bool>  vis;
void solve()
{
    vis.clear();
    scanf("%d", &n);
    string s;
    ans = 0;
    while(n--)
    {
        cin>>s;
        if(!vis[s]) ans++;
        vis[s] = 1;
    }
    printf("%d\n", ans);
}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d", &n))
//    while(scanf("%d", &n)&&n)
    solve();
    return 0;
}


Measured memory_bytes: 19316
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, W = il()
    A = [iss() for _ in range(H)]

    print('#' * (W + 2))
    for a in A:
        str = '#' + a + '#'
        print(str)
    print('#' * (W + 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>=m)
    {
        while(n--)
        {
            cout<<m;
        }        
    }
    else
    {
         while(m--)
         {
             cout<<n;
         }
    }
    
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (w, h, n): (usize, usize, usize) = parse_line().unwrap();

    let mut is_white: Vec<Vec<bool>> = vec![];
    for _ in 0..w {
        let mut v = vec![];
        for _ in 0..h {
            v.push(true);
        }
        is_white.push(v);
    }
    for _ in 0..n {
        let (x, y, a): (usize, usize, usize) = parse_line().unwrap();
        let (x_range, y_range) = match a {
            1 => (0..x, 0..h),
            2 => (x..w, 0..h),
            3 => (0..w, 0..y),
            4 => (0..w, y..h),
            _ => unreachable!(),
        };

        for i in x_range {
            for j in y_range.clone() {
                is_white[i][j] = false;
            }
        }
    }

    let mut ret = 0;
    for i in 0..w {
        for j in 0..h {
            if is_white[i][j] {
                ret += 1;
            }
        }
    }

    println!("{}", ret);
}


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


using namespace std;

int main()
{

	while (true) {

		int n;
		cin >> n;
		if (n == 0) {
			return 0;
		}
		string str;
		int nums[41];

		for (int i = 0; i < n; i++) {
			cin >> str;
			nums[i] = str.size();
		}

		int start = 0;
		int tail = 0;
		int sum = 0;
		while (true) {
			while (tail < n && sum < (5 + 7 + 5 + 7 + 7)) {
				tail++;

				sum = 0;
				for (int i = start; i < tail; i++) {
					sum += nums[i];
				}
			}
			if (sum < (5 + 7 + 5 + 7 + 7)) {
				break;
			}
			else if (sum == (5 + 7 + 5 + 7 + 7)) {
				int ns[5] = { 5, 7, 5, 7, 7 };
				int s = start;
				int i = 0;
				while (i < 5) {
					if (nums[s] == ns[i]) {
						i++;
						s++;
					}
					else if (nums[s] > ns[i]) {
						break;
					}
					else {
						ns[i] = ns[i] - nums[s];
						s++;
					}
				}
				if (i == 5) {
					cout << start + 1 << endl;
					break;
				}

			}

			start++;
			sum = 0;
			for (int i = start; i < tail; i++) {
				sum += nums[i];
			}

		}
	}

	return 0;
}

Measured memory_bytes: 3116
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x = gi();
    int y = gi();
    int res = 0;
    if (x < 4)
        res += 100000 * (4-x);
    if (y < 4)
        res += 100000 * (4-y);
    if (x == 1 && y == 1)
        res += 400000;

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 256
listA = []
listB = []
Answer = []
n, m = map(int, input().split())
for i in range(n):
    listA.append(list(map(int, input().split())))
for j in range(m):
    listB.append(int(input()))
for k in range(n):
    result = 0
    for l in range(m):
        result += listA[k][l]*listB[l]
    Answer.append(result)
for p in range(n):
    print(Answer[p])


Measured memory_bytes: 6012
N=int(input())
A=[int(input()) for _ in range(N)]
B=max(A)

if A.count(B) == 1:
    for i in range(0,N):
        if A[i] == B:
            A[i] = 0
            print(max(A))
        else:
            print(B)
else:
    for i in range(0,N):
        print(B)

Measured memory_bytes: 12580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 2005;
const int mod = 1e9+7;

char g[maxn][maxn];int h,w;
int cur[2],tr[2][2],bla,hor,sam1,sam2;LL K;
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
void mulcur() {
	int a=cur[0],b=cur[1];
	cur[0]=((LL)a*tr[0][0]+(LL)b*tr[1][0])%mod;
	cur[1]=((LL)a*tr[0][1]+(LL)b*tr[1][1])%mod;
}
void multr() {
	int a00=tr[0][0],a01=tr[0][1];
	int a10=tr[1][0],a11=tr[1][1];
	tr[0][0]=((LL)a00*a00+(LL)a01*a10)%mod;
	tr[0][1]=((LL)a00*a01+(LL)a01*a11)%mod;
	tr[1][0]=((LL)a10*a00+(LL)a11*a10)%mod;
	tr[1][1]=((LL)a10*a01+(LL)a11*a11)%mod;
}
int main()
{
	#ifdef Amberframe
		freopen("agc003f.in","r",stdin);
		freopen("agc003f.out","w",stdout);
	#endif
	scanf("%d %d %lld",&h,&w,&K);
	for (int i=1;i<=h;i++) scanf("%s",g[i]+1);
	for (int i=1;i<=h;i++)
	for (int j=1;j<=w;j++) bla+=(g[i][j]=='#');
	for (int i=1;i<=h;i++) sam1+=(g[i][1]=='#'&&g[i][w]=='#');
	for (int i=1;i<=w;i++) sam2+=(g[1][i]=='#'&&g[h][i]=='#');
	if (!sam1&&!sam2) printf("%lld",fpm(bla,K-1));
	else if (sam1&&sam2) printf("1");
	else {
		if (sam1) {
			for (int i=1;i<=h;i++)
			for (int j=1;j<=w;j++)
				hor+=(g[i][j]=='#'&&g[i][j+1]=='#');
		}
		else {
			for (int i=1;i<=h;i++)
			for (int j=1;j<=w;j++)
				hor+=(g[i][j]=='#'&&g[i+1][j]=='#');
		}
		cur[0]=1;cur[1]=0;
		tr[0][0]=bla;tr[0][1]=hor;tr[1][1]=(sam1+sam2)%mod;
		for (K--;K;K>>=1,multr()) if (K&1) mulcur();
		int ans=(cur[0]-cur[1])%mod;
		printf("%d",ans<0?ans+mod:ans);
	}
	return 0;
}

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

int64_t n, x;
vector<int64_t> num, p_num;

int64_t f(int64_t index, int64_t k)
{
	if (x <= index)
	{
		return 0;
	}
	if (index + num[k] <= x)
	{
		return p_num[k] + (index + num[k] < x) + f(index + num[k] + 1, k);
	}
	else
	{
		return f(index + 1, k - 1);
	}
}

int main()
{
	cin >> n >> x;
	num.resize(n + 1);
	p_num.resize(n + 1);
	num[0] = 1;
	p_num[0] = 1;
	for (int i = 0; i < n; i++)
	{
		num[i + 1] = 2 * num[i] + 3;
		p_num[i + 1] = 2 * p_num[i] + 1;
	}
	cout << f(0, n) << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

template<class T> struct flow {
  struct edge {
    int to;
    T cap;
    int rev;
  };

  int n, s, t;
  vector<vector<edge>> g;
  vector<bool> used;

  flow(int n, int s, int t) : n(n), s(s), t(t) {
    g = vector<vector<edge>>(n);
  }

  void add(int from, int to, T cap) {
    g[from].push_back({ to, cap, (int) g[to].size() });
    g[to].push_back({ from, 0, (int) g[from].size() - 1 });
  }

  T dfs(int v, int t, T f) {
    if (v == t) {
      return f;
    }
    used[v] = true;
    for (auto &e : g[v]) {
      if (used[e.to] || e.cap <= 0) {
        continue;
      }
      T d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }

  T max_flow() {
    T flow = 0;
    while (true) {
      used = vector<bool>(n);
      T f = dfs(s, t, numeric_limits<T>::max());
      if (f == 0) {
        break;
      }
      flow += f;
    }
    return flow;
  }
};

int main() {
  ioinit();
  int n;
  cin >> n;
  vi32 a(n);
  rep(i, n) cin >> a[i];
  flow<i64> g(n + 2, 0, n + 1);
  rep(i, n) {
    if (a[i] <= 0) {
      g.add(0, i + 1, -a[i]);
    } else {
      g.add(i + 1, n + 1, a[i]);
    }
  }
  reps(i, n) {
    for (int j = i + i; j <= n; j += i) {
      g.add(i, j, numeric_limits<i64>::max());
    }
  }
  i64 ans = 0;
  rep(i, n) ans += max(0, a[i]);
  ans -= g.max_flow();
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256