akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int B[111];

signed main(){
	cin>>N;
	rep(i,N)cin>>B[i],B[i]--;

	vint uku;
	for(int i=N;i>0;i--){
		int x=-1;
		for(int j=i-1;j>=0;j--){
			if(B[j]==j){
				x=j;
				break;
			}
		}
		if(x==-1){
			cout<<-1<<endl;
			return 0;
		}
		uku.pb(x);
		for(int j=x;j+1<i;j++)B[j]=B[j+1];
	}

	reverse(all(uku));
	rep(i,N)cout<<uku[i]+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,m;
    cin>>n>>m;
    string a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    cout<<a[i];}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

vector<int> g[200010];
vector<ll> v(200010);

void dfs(int now, int bef, ll sum) {
  sum += v[now];
  v[now] = sum;
  if (now != 0 && g[now].size() == 1) return;
  for (auto x : g[now]) {
    if (x != bef) dfs(x, now, sum);
  }
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

// ====================================================================

int main() {
  int n, q;
  cin >> n >> q;
  v.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  for (int i = 0; i < q; i++) {
    int p, x;
    cin >> p >> x;
    p--;
    v[p] += x;
  }
  dfs(0, -1, 0);

  cout << v << endl;
}


Measured memory_bytes: 24320
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC diagnostic error "-std=c++14"

#define isNum(a) (a>='0'&&a<='9')
#define SP putchar(' ')
#define EL putchar('\n')
#define ri register int

template<class T>
inline void in(T&);
template<class T>
inline void out(const T&);

typedef long long ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
using namespace std;

int n,a[2005],ans;

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    in(n);
    for (ri i=1;i<=n;++i) in(a[i]);
    sort(a+1,a+n+1);
    for (ri i=1;i<=n;++i)
    {
    	for (ri j=i+1;j<=n;++j)
    	{
    		for (ri k=j+1;k<=n;++k)
    		{
    			if (a[i]+a[j]>a[k]) ++ans;
			}
		}
	}
	out(ans);EL;
    return 0;
}

template<class T>
void in(T &Re)
{
    T k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch))
	{
        if (ch=='-')
		{
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch))
	{
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    Re=flag*k;
}

template<class T>
void out(const T &Wr)
{
    if (Wr<0)
	{
        putchar('-');
        out(-Wr);
    }
	else
	{
        if (Wr<10)
		{
            putchar(Wr+'0');
        }
		else
		{
            out(Wr/10);
            putchar((Wr%10)+'0');
        }
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>


using namespace std;
using namespace __gnu_pbds;

#define int long long int
#define pb push_back
#define M 998244353
#define ff first
#define ss second
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define ffo(i,k,n) for(int i=k;i<=n;i++)
#define ffORR(a,b,c) for(int a= b;a>=c;a--)
#define fa(defr) for(auto x:defr)
#define sz size()
// #define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MarX 100005
#define PII pair<int,int>
#define aint(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);


// typedef tree<pair<int, int>,
//         nuint_type,
//         less<pair<int, int>>,
//         rb_tree_tag,
//         tree_order_statistics_node_update> oset;

//126271
// 107897


int lcm(int a, int b) {
	int x = (a * b) % M;
	return x / __gcd(a, b);
}

int ceil(int a, int b) {
	if (a % b != 0) return a / b + 1;
	return a / b;
}


int power(int x, int y, int p)
{
	int res = 1LL;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

int pow1(int n) {
	int ans = power(2, n, M);
	ans = (ans - 1 + M) % M;
	return ans % M;
}


int32_t main() {

	fast;
	int t;
	// cin >> t;
	t = 1;
	// int tc = 1;
	while (t--) {
		// solve();
		int n,k; cin >> n >> k;
		vector<int>arr(n+1), dp(n+1, 1e9);
		for(int i = 1;i<=n;i++)  cin >> arr[i];
		dp[1] = 0;
		for(int i = 2;i<=n;i++){
			for(int j = i-1;j>=max(1LL, i-k);j--){
				dp[i] = min(dp[i], dp[j] + abs(arr[j] - arr[i]));
			}
		}
		cout << dp[n] << endl;
	}

}


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

s.sort()

n=len(s)

c=1
f=1
now=s[0]

for i in range(1,n):
    if now==s[i]:
        c+=1
    else:
        if c%2==1:
            f=-1
        c=1
        now=s[i]
else:
    if c%2==1:
        f=-1

if f<0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
def can_put?(wmax, k, wi)
  cap = 0
  num = 1
  wi.each do |w|
    cap += w
    if cap > wmax
      cap = w
      num += 1
      return false if num > k || cap > wmax
    end
  end
  num <= k
end

def solve(k, wi)
  lb, ub = 0, wi.inject(&:+)
  while ub - lb > 1
    mid = (ub+lb)/2
    if can_put?(mid, k, wi)
      ub = mid
    else
      lb = mid
    end
  end
  ub
end

n, k = gets.split(" ").map(&:to_i)
wi = Array.new(n) { gets.to_i }
puts solve(k, wi)



Measured memory_bytes: 8900
#include <stdio.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv){
    int A1;
    int A2;
    int A3;
    cin >> A1 >> A2>>A3;
    if(A1+A2+A3>=22){
        cout<<"bust";
    }else{
        cout<<"win";
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]

cnt = Counter(a)
if len(cnt) == 1:
    color_num = max(cnt)
    if color_num == n-1 or color_num <= n // 2:
        print("Yes")
    else:
        print("No")
elif len(cnt) == 2:
    color_num = max(cnt)
    # Cout can be 2 sequential number
    if color_num - 1 not in cnt:
        print("No") 
        exit()
    if cnt[color_num-1] <= color_num - 1 and cnt[color_num-1] >= 2*color_num - n:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 18656
#include <stdio.h>

void main(void){
    char S[100];

    scanf("%s", S);

    if(S[0] == 'S'){
        printf("Cloudy\n");
    }
    else if(S[0] == 'C'){
        printf("Rainy\n");
    }
    else{
        printf("Sunny\n");
    }
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;


	public void _main(String[] args) {
		Scanner sc = new Scanner(in);
		
		String S = sc.next();
		
		List<List<Integer>> a = new ArrayList<>();
		for(int i=0;i<S.length();i++) {
			a.add(Arrays.asList(i, S.charAt(i) == 'W' ? 0 : 1));
		}
		
		a.sort((o1, o2) -> Integer.compare(o1.get(1), o2.get(1)));
		
		long ans = 0;
		for(int i=0;i<S.length();i++) {
			List<Integer> x = a.get(i);
			if(x.get(1) == 0) {
				ans += Math.abs(i-x.get(0));
			}
		}
		out.println(ans);
		
		
	}

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

}


Measured memory_bytes: 53332
import math

n = int(input())

n_sqrt = int(math.sqrt(n))

i = 1
yaku = []
while i**2<=n:
    if n%i==0:
        yaku.append(i)
        yaku.append(n//i)
    i += 1
yaku = list(set(yaku))
del(yaku[0])

ylen = len(yaku)

sosu = []
Yaku = []
for i in range(ylen):
    
    j = 1
    table = []
    while j**2<=yaku[i]:
        if yaku[i]%j==0:
            table.append(j)
            table.append(yaku[i]//j)
        j += 1
    table = list(sorted(set(table)))
    
    if len(table)==2:
        sosu.append(yaku[i])

for i in range(len(sosu)):
    for j in range(len(sosu)-1,0,-1):
        if sosu[j-1]>sosu[j]:
            sosu[j-1],sosu[j] = sosu[j],sosu[j-1]

Count = []
m = n
for i in range(len(sosu)):
    count = 0
    while True:
        m = m/sosu[i]
        count += 1
        if m%sosu[i]==0:
            pass
        else:
            Count.append(count)
            break

print(n,end='')
print(':',end=' ')
for i in range(len(sosu)):
    for j in range(Count[i]):
        if i==len(sosu)-1 and j==Count[i]-1:
            print(sosu[i])
        else:
            print(sosu[i],end=' ')


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n, m;
int a[31];

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> n; cin >> m;
    REP(i,n) {
        int k; cin >> k;
        REP(j,k) {
            int x; cin >> x;
            a[x]++;
        }
    }
    int cnt = 0;
    REP(i,m+1) {
        if(a[i] == n) cnt++;
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int ma = 0;
    rep(i, n) {
        cin >> a[i];
        chmax(ma, a[i]);
    }
    map<int, int> mp;
    rep(i, n) {
        if(a[i] < (ma + 1) / 2) {
            cout << "Impossible" << endl;
            return;
        }
        mp[a[i]] ++;
    }
    if(ma % 2 == 0) {
        if(mp[ma / 2] != 1) {
            cout << "Impossible" << endl;
            return;
        }
    }
    if(ma % 2 == 1) {
        if(mp[(ma + 1) / 2] != 2) {
            cout << "Impossible" << endl;
            return;
        }
    }
    for(int i = (ma + 2) / 2; i <= ma; ++i) {
        if(mp[i] < 2) {
            cout << "Impossible" << endl;
            return;
        }
    }
    cout << "Possible" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np 

EPS = np.float128(1.0e-15)

arg = input().split(' ')
a = np.float128(int(arg[0]))
b = np.float128(int(arg[1]))
c = np.float128(int(arg[2]))

if np.sqrt(a) + np.sqrt(b) + EPS < np.sqrt(c):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21992
#include <iostream>
#include <queue>

using namespace std;

int G[100][100];
int In[100];
int Out[100];
void init() {
	for (int i = 0; i < 100; i++) {
		for(int j = 0; j < 100; j++)
			G[i][j] = 0;
		In[i] = -1;
		Out[i] = -1;
	}	
}

void dfs(int src);

int main() {
	init();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v_j;
			cin >> v_j;
			G[u - 1][v_j - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		if (In[i] == -1) dfs(i);		
	}
	for (int i = 0; i < n; i++)
		cout << i + 1 << " " << In[i] << " " << Out[i] << endl;
}

int t = 1;

void dfs(int cur) {
	In[cur] = t;
	t++;
	for (int dst = 0; dst < 100; dst++)
		if (G[cur][dst] == 1 && In[dst] == -1)
			dfs(dst);
	Out[cur] = t;
	t++;
}

Measured memory_bytes: 1200
const Main = (input) => {
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    var ans = xs[0] + xs[1];
    //console.log(xs);
    if(xs[0] % 3 == 0 || xs[1] % 3 == 0 || ans % 3 == 0){
    	console.log('Possible');
    }else if(ans % 3 != 0){
    	console.log('Impossible');
    }
    
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

//Shopping in JOI Kingdom
public class Main{

	int n, m, k, INF = 1<<29;
	List<E>[] adj;
	int[] d;
	
	class E{
		int t, c;
		public E(int t, int c) {
			this.t = t;
			this.c = c;
		}
	}
	
	void dijkstra(int x){
		d[x] = 0;
		PriorityQueue<Integer> q = new PriorityQueue<Integer>(n, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return d[o1]-d[o2];
			}
		});
		q.add(x);
		while(!q.isEmpty()){
			int v = q.poll();
			for(E e:adj[v]){
				int w = d[v]+e.c;
				if(w<d[e.t]){
					q.remove(e.t); d[e.t] = w; q.add(e.t);
				}
			}
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt();
		adj = new List[n];
		for(int i=0;i<n;i++)adj[i]=new ArrayList<E>();
		d = new int[n];
		Arrays.fill(d, INF);
		while(m--!=0){
			int s = sc.nextInt()-1, t = sc.nextInt()-1, c = sc.nextInt();
			adj[s].add(new E(t, c)); adj[t].add(new E(s, c));
		}
		while(k--!=0)dijkstra(sc.nextInt()-1);
		double res = 0;
		for(int i=0;i<n;i++)for(E e:adj[i]){
			int dif = Math.abs(d[i]-d[e.t]);
			if(d[i]<d[e.t])res = Math.max(res, d[i]+dif+(e.c-dif)/2.0);
			else res = Math.max(res, d[e.t]+dif+(e.c-dif)/2.0);
		}
		System.out.printf("%.0f\n", res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

const int INF = 1e9 + 7;


int a[ARRAY_MAX][ARRAY_MAX];
int dp[ARRAY_MAX][ARRAY_MAX];

int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	int h, w;
	cin >> h >> w;
	
	for (int i = 0; i < h; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < w; j++)
		{
			a[i][j] = s[j] - '0';
		}
	}

	for (int i = 0; i < w; i++) {
		dp[0][i] = a[0][i];
	}
	for (int i = 0; i < h; i++) {
		dp[i][0] = a[i][0];
	}

	for (int i = 0; i < w-1; i++) {
		dp[0][i+1] += dp[0][i];
	}
	for (int i = 0; i < h-1; i++) {
		dp[i+1][0] += dp[i][0];
	}

	for (int i = 1; i < h; i++)
	{
		for (int j = 1; j < w; j++)
		{
			dp[i][j] = min(dp[i - 1][j] + a[i][j], dp[i][j - 1] + a[i][j]);
		}
	}
	cout << dp[h - 1][w - 1] << endl;


	return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  long long n,m;
  cin >> n >> m;
  pair<long long, long long> drink[100000];

  for (int i = 0;i < n;i++)
  {
    cin >> drink[i].first >> drink[i].second;
  }

  sort(drink, drink + n);

  long long ans = 0;
  long long buy  = 0;
  
  for (int i = 0;i < n;i++)
  {
    if (buy == m)
    {
      break;
    }
    
    if (drink[i].second >= m - buy)
    {
      ans += (m - buy) * drink[i].first;
      buy += (m - buy);
    }
    else
    {
      ans += drink[i].second * drink[i].first;
      buy += drink[i].second;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792
sumN :: [Int] -> [Int] -> Int -> Int
sumN a1s a2s n = s1 + s2
  where
    s1 = sum (take (n + 1) a1s)
    s2 = sum (drop n a2s)

solve :: Int -> [Int] -> [Int] -> Int
solve valN a1s a2s =
  maximum (map (sumN a1s a2s) [0 .. valN-1])

main :: IO ()
main = do
  cont <- getContents
  let valN : as = map read (words cont)
      (a1s, a2s) = splitAt valN as
      answer = solve valN a1s a2s
  putStrLn $ show $ answer


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int>ki[100005];
int dp[100005][2];
void dfs(int now) {
    dp[now][0] = dp[now][1] = 1;
    for(int i = 0; i < ki[now].size(); i++) {
        if(dp[ki[now][i]][0] == 0) {
            dfs(ki[now][i]);
            dp[now][0] *= dp[ki[now][i]][0]+dp[ki[now][i]][1];
            dp[now][1] *= dp[ki[now][i]][0];
            dp[now][0] %= mod;
            dp[now][1] %= mod;
        }
    }
    return;
}
signed main(){
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    dfs(0);
    cout << (dp[0][0]+dp[0][1])%mod << endl;
}


Measured memory_bytes: 14732
#include<bits/stdc++.h> 
using namespace std;
char a[1000];
int main()
{
cin>>a;
for(int i=0;i<strlen(a);i++)
{
	if (a[i]=='C') 
	 {
	 	for(int ii=i+1;ii<strlen(a);ii++)
	 	 {
	 	 	if (a[ii]=='F') {cout<<"Yes"<<endl;return 0;}
	 	 }
	 }
}
cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new KK(); }
class KK
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	double[] GR => Strs.Select(double.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	public const int MOD = 1000000007;
	public const long INFL = 4011686018427387913L;
	public KK()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	string K;
	int D;
	void Solve()
	{
		K = Str;
		D = F;
		dp = new long[K.Length + 1, 2, D];
		done = new bool[K.Length + 1, 2, D];
		WriteLine((Calc() - 1 + MOD) % MOD);
	}
	long[,,] dp;
	bool[,,] done;
	long Calc(int k = 0, bool t = true, int s = 0)
	{
		var t2 = t ? 1 : 0;
		if (!done[k, t2, s])
		{
			done[k, t2, s] = true;
			if (k == K.Length) dp[k, t2, s] = s == 0 ? 1 : 0;
			else
			{
				var x = K[k] - '0';
				var r = t ? x : 9;
				for (var i = 0; i <= r; ++i) dp[k, t2, s] = (dp[k, t2, s] + Calc(k + 1, t && i == r, (s + i) % D)) % MOD;
			}
		}
		return dp[k, t2, s];
	}
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    i64 ans = 1e10;
    rep(i, n - k + 1) ans = min(ans, a[i + k - 1] - a[i]);
    cout << ans << endl;
    return 0;
}


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


int used[100010];

void dfs(int u, const vector<vector<int>>& g) {
	used[u] = true;
	for (auto v : g[u]) {
		if (!used[v]) dfs(v, g);
	}
}

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> x(m), y(m), z(m); rep(i, m) cin >> x[i] >> y[i] >> z[i];
	rep(i, m) x[i]--, y[i]--;

	vector<vector<int>> g(n);
	rep(i, m) {
		g[x[i]].push_back(y[i]);
		g[y[i]].push_back(x[i]);
	}
	int ans = 0;
	rep(i, n) {
		if (!used[i]) {
			ans++;
			dfs(i, g);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var left = (long)0;
            var wcnt = 0;
            //左に移動する場合
            foreach(var i in Enumerable.Range(0, S.Length))
            {
                var schar = S[i];

                if(schar == 'W')
                {
                    left += i - wcnt;
                    wcnt++;
                }
            }
            Console.WriteLine(left);
        }
    }
}


Measured memory_bytes: 14176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        long n = int.Parse(Console.ReadLine());
        long ans = 0;
        Dictionary<char, long> dict = new Dictionary<char, long>();
        
        for(int i = 0; i < n; i++)
        {
            char c = Console.ReadLine()[0];
            dict[c] = dict.ContainsKey(c) ? dict[c] + 1 : 1;
        }

        if(dict.Count >= 3)
        {
            long[] count = new long[5];
            count[0] = dict.ContainsKey('M') ? dict['M'] : 0;
            count[1] = dict.ContainsKey('A') ? dict['A'] : 0;
            count[2] = dict.ContainsKey('R') ? dict['R'] : 0;
            count[3] = dict.ContainsKey('C') ? dict['C'] : 0;
            count[4] = dict.ContainsKey('H') ? dict['H'] : 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    for (int k = j + 1; k < 5; k++)
                    {
                        ans += count[i] * count[j] * count[k];
                    }
                }
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

using namespace std;

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

    int m, k;
    cin >> m >> k;

    if (m == 1) {
        if (k == 0) cout << "0 0 1 1\n";
        else cout << "-1\n";
    } else {
        if (k > (1 << m) - 1) cout << "-1\n";
        else {
            for (int i = 0; i < (1 << m); i++)
            {
                if (i == k) continue;
                cout << i << " ";
            }
            cout << k << " ";
            for (int i = (1 << m) - 1; i >= 0; i--)
            {
                if (i == k) continue;
                cout << i << " ";
            }
            cout << k << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	long long a, b, c;
	long long s[3];
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		s[0] = a*b;
		s[1] = b*c;
		s[2] = c*a;
		sort(s, s + 3);
		cout << s[0] << endl;
	}

}

Measured memory_bytes: 256
var
	M,L,R,ans,ll,rr:int64;
    k,i,x,y,xl,yl,limx,limy,xx,yy,id,ie:Longint;
    dp:array[1..64,1..2,1..2]of int64;
begin
	read(L,R);
    M:=1000000007;
    ll:=1;
    rr:=2;
    for k:=1 to 60 do begin
    	if(rr<=L)or(R<ll)then begin
        	ll:=ll*2;
            rr:=rr*2;
        	continue;
        end;
        for i:=1 to 61 do for xx:=1 to 2 do for yy:=1 to 2 do dp[i,xx,yy]:=0;
        if L<=ll then if rr-1<=R then dp[1,2,2]:=1 else dp[1,2,1]:=1 else if rr-1<=R then dp[1,1,2]:=1 else dp[1,1,1]:=1;
        for i:=1 to k-1 do begin
        	x:=(L>>(k-1-i))mod 2;
            y:=(R>>(k-1-i))mod 2;
            for xl:=1 to 2 do begin
            	if xl=1 then limx:=x else limx:=0;
                for yl:=1 to 2 do begin
                	if dp[i,xl,yl]=0 then continue;
                	if yl=1 then limy:=y else limy:=1;
                    for yy:=0 to limy do begin
                    	for xx:=limx to yy do begin
                        	if(xl=2)or(xx>limx)then id:=2 else id:=1;
                            if(yl=2)or(yy<limy)then ie:=2 else ie:=1;
                            dp[i+1,id,ie]:=(dp[i+1,id,ie]+dp[i,xl,yl])mod M;
                        end;
                    end;
                end;
            end;
        end;
        ll:=ll*2;
        rr:=rr*2;
        ans:=(ans+dp[k,1,1]+dp[k,1,2]+dp[k,2,1]+dp[k,2,2])mod M;
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll col[N],ans[N],cnt[2];
vector<ll> adj[N],pos[3];
void dfs(ll node,ll pr){
    col[node]=(col[pr]^1);
    cnt[col[node]]++;
    for(auto &u:adj[node])if(u!=pr)dfs(u,node);
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<n;i++){
        ll a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(ll i=1;i<=n;i++)pos[i%3].push_back(i);
    dfs(1,0);
    ll s=0;
    if(cnt[1]<cnt[0])s=1;

    if(cnt[s]<=pos[0].size()){
        for(ll i=1;i<=n;i++){
            if(col[i]==s){
                ans[i]=pos[0].back();
                pos[0].pop_back();
            }
        }
    }
    else{
        for(ll i=1;i<=n;i++){
            if(col[i]==s){
                if(!pos[s+1].empty()){
                    ans[i]=pos[s+1].back();
                    pos[s+1].pop_back();
                }
                else{
                    ans[i]=pos[0].back();
                    pos[0].pop_back();
                }
            }
        }
    }

    for(ll i=1;i<=n;i++){
        if(!ans[i]){
            for(ll j=0;j<3;j++){
                if(!pos[j].empty()){
                    ans[i]=pos[j].back();
                    pos[j].pop_back();
                    break;
                }
            }
        }
    }

    for(ll i=1;i<=n;i++)cout<<ans[i]<<" ";
}



Measured memory_bytes: 21996
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)
var lazy []int
var n int
var INF = math.MaxInt32
var D []int
func main() {
	var out = bufio.NewWriter(os.Stdout)
	var in = bufio.NewReader(os.Stdin)
	var q int
	fmt.Fscanf(in, "%d %d\n", &n, &q)
	n = int(math.Ceil(math.Log2(float64(n))))
	if n == 0 {
		n++
	}
	n = 1 << uint(n)
	lazy = make([]int, 2*n-1)
	InitA()
	var a, b, c, d int
	for i := 0; i < q; i++ {
		fmt.Fscanf(in, "%d", &a)
		if a == 0 {
			fmt.Fscanf(in, "%d %d %d\n", &b, &c, &d)
			update(b, c+1, 0, 0, n, d)
		} else {
			fmt.Fscanf(in, "%d %d\n", &b, &c)
			out.Flush()
			fmt.Fprintln(out, findMin(b, c))
		}
	}
	out.Flush()
}
func InitA() {
	for i := 0; i < 2*n-1; i++ {
		lazy[i] = -1
	}
	D = make([]int, 2*n-1)
	for i := 0; i < 2*n-1; i++ {
		D[i] = INF
	}
}
func lazy_evaluate(k int) {
	if lazy[k] != -1 {
		D[k] = lazy[k]
		if k < n-1 {
			lazy[2*k+1] = lazy[k]
			lazy[2*k+2] = lazy[k]
		}
		lazy[k] = -1
	}
}
func update(a, b, k, l, r, v int) {
	if r <= a || b <= l {
		lazy_evaluate(k)
		return
	}
	if a <= l && r <= b {
		lazy[k] = v
		lazy_evaluate(k)
		return
	}
	lazy_evaluate(k)
	update(a, b, 2*k+1, l, (l+r)/2, v)
	update(a, b, 2*k+2, (l+r)/2, r, v)
	D[k]=min(D[2*k+1],D[2*k+2])
}


func findMin(a, b int) int {
	return query(a, b+1, 0, 0, n)
}
func query(a, b, k, l, r int) int {
	if r <= a || b <= l {
		return INF
	}
	if a <= l && r <= b {
		lazy_evaluate(k)
		return D[k]
	}
	lazy_evaluate(k)
	vl := query(a, b, 2*k+1, l, (l+r)/2)
	vr := query(a, b, 2*k+2, (l+r)/2, r)
	return min(vl, vr)
}
func min(a, b int) int {
	if a <= b {
		return a
	} else {
		return b
	}
}



Measured memory_bytes: 7852
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    ll a,b;
    cin>>a>>b;
    ll ans;
    bool flag = false;
    for(ll i = 1;i<=100000;i++)
    {
        ll val1 = floor(i*(0.08));
        ll val2  = floor(i*(0.1));
        if(val1 == a && val2 == b)
        {
            flag = true;
            ans = i;
            break;
        }
    }
    if(flag)
    {cout<<ans<<"\n";}
    else
    {
        cout<<-1<<"\n";
    }
    
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	_, K := sc.nextInt(), sc.nextInt()
	S := sc.nextRuneSlice()
	fmt.Print(string(S[:K-1]), strings.ToLower(string(S[K-1])), string(S[K:]))
	fmt.Println()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  int len = 1, ans = 0;
  rep(i, n) {
    if(a[i]) {
      if(i && a[i - 1]) {
        len++;
        ans = max(len, ans);
      } else {
        len = 1;
        ans = max(len, ans);
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}



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

using namespace std;

int game(int num, int stone)
{
        int i = 0, in_the_box = stone;
        vector<int> mayor(num, 0);
        while(1){
                if(in_the_box != 0){
                        mayor[i] += 1;
                        in_the_box -= 1;
                        if(mayor[i] == stone){
                                break;
                        }
                }else if(mayor[i] != 0){
                        in_the_box = mayor[i];
                        mayor[i] = 0;
                }

                i = (i + 1) % num;
        }
        return i;
}

int main(void)
{
        int i, n, p, next_mayor;

        while(1){
                cin >> n >> p;
                if(n == 0 && p == 0)
                        break;

                next_mayor = game(n, p);
                cout << next_mayor << endl;
        }
        return 0;
}

Measured memory_bytes: 3076
import sys
input = sys.stdin.readline

def io_generator():
	return input()
	
def ioByFile(fn='inputFile.txt'):
	with open(fn) as f:
		for line in f:
			yield line[:-1]

#+++++ +++++ +++++#
		
def main(a_io):
	p, q, r = map(int, a_io().split())
	ret=min(p+q,q+r,r+p)
	print(ret)
	
#+++++ +++++ +++++#

if __name__ == "__main__":
	io= lambda : io_generator()
	if sys.platform =='ios':
		testInput=ioByFile()
		io=lambda : next(testInput)
	main(io)

Measured memory_bytes: 3064
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1e9+9;
int n;
int a[29];
int b[20];
int c[20];
int main(){
	fast,cin>>n;
	for(int i=0;i<n;i++) cin>>a[i],a[i]--;
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n-1;i++) cin>>c[i];
	int sum = b[a[0]];
	for(int i=1;i<n;i++){
		sum += b[a[i]];
		if(a[i] == a[i-1]+1) sum += c[a[i]-1];
	}
	cout<<sum<<endl;
}


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

class Dice{
public:
  int face[6];
  Dice(){}

  void roll_x(){ roll(0,3,5,2);}
  void roll_y(){ roll(0,1,5,4);}
  void roll(int i, int j, int k, int l){
    int t = face[i]; face[i] = face[j]; face[j] = face[k]; face[k] = face[l]; face[l] = t;
  }

  void move(char ch){
    if (ch == 'S'){
      for(int i = 0; i < 3; i++) roll_y();
    }
    else if (ch == 'W'){
      for(int i = 0; i < 3; i++) roll_x();
    }
    else if (ch == 'N'){
      roll_y();
    }
    else if (ch == 'E'){
      roll_x();
    }
  }
};

int main(){
  string dir;
  Dice d1;
  for (int i = 0; i < 6; i++){
    cin >> d1.face[i];
  }
  cin >> dir;

  for (int i = 0; i < dir.size(); i++){
    d1.move(dir[i]);
  }

  cout << d1.face[0] <<endl;

  return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int n,count=0;
    cin>>n;
    vector<int> v(n,0);
    rep(i,n) cin>>v[i];
    int a;
    rep(i,n){
        count++;
        if(i==0) a=i;
        if(v[a]==2){
            cout<<count<<endl;
            return 0;
        } 
        else{
            a=v[a]-1;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  if(n<1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}


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

int64_t gcd(int64_t a , int64_t b)
{
	if (a<b){swap(a,b);}
	// a > b とする。
	if (b == 0){return a;}
	while(b){
		int64_t r = a%b;
		a = b;
		b = r;
	}
	return a;
}

int64_t lcm(int64_t a, int64_t b)
{
	if (a<b){swap(a,b);}
	// a > b とする。
	if (a%b == 0){return a;}
	int64_t g = gcd(a,b);
	return a/g *b ;
}

int main(int argc, char** argv)
{
	(void)argc;
	(void)argv;
	vector<int64_t> vec;
	int N;
	cin >> N;

	for(int i=0;i<N;i++){
		int64_t a;
		cin >> a;
		vec.push_back(a);
	}

	int64_t L=vec[0];
	for(int i=1;i<N;i++)
	{
		L=lcm(vec[i],L);
	}
	printf("%ld\n",L);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//static const ll MOD = 1e+9 + 7;
//static const int MAX = 10001;


int main() {

  ll S; cin >> S;

  ll x1 = 1e+9;
  ll y2 = (S + (x1 - 1)) / x1;
  ll y1 = x1 * y2 - S;
  cout << 0 << ' ' << 0 << ' ' << x1 << ' ' 
      << y1 << ' ' << 1 << ' ' << y2 << '\n';

}



Measured memory_bytes: 256
while True:
   H,W=map(int,raw_input().split())
   if H==W==0:
       break
   elif H!=0 or W!=0:
     for i in range(0,H):
       if i%2 == 0:
         if W%2 == 1:
           print '#.'*(W/2)+'#'
         elif W%2 == 0:
           print '#.'*(W/2)
       else:
         if W%2 == 1:
           print '.#'*(W/2)+'.'
         elif W%2 == 0:
           print '.#'*(W/2)
     print ''

Measured memory_bytes: 6376
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;

int main() {
  string S;
  cin >> S;
  
  ll a = 0, ab = 0, abc = 0;
  ll pattern = 1;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A') {
      a += pattern;
    }
    if (S[i] == 'B') {
      ab += a;
    }
    if (S[i] == 'C') {
      abc += ab;
    }
    if (S[i] == '?') {
      abc = abc * 3 + ab;
      ab  = ab * 3 + a;
      a   = a * 3 + pattern;
      pattern *= 3;
    }
    abc %= MOD;
    ab  %= MOD;
    a   %= MOD;
    pattern %= MOD;
  }
  cout << abc << endl;
  return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a;cin >> n >> a;
	vector<int> x(n);
	rep(i,n){
		cin >> x.at(i);
	}
	ll dp[51][51][2510];
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			rep(k,2501){
				if(i>0 && k-x[i-1]>=0 && j>0 ) dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k];
				else if(i>0 && k-x[i-1]<0) dp[i][j][k]=dp[i-1][j][k];
				else if(i==0 && j==0 && k==0) dp[i][j][k]=1;
				else dp[i][j][k]=0;
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;++i){
		ans+=dp[n][i][i*a];
	}
	cout << ans << endl;
}

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

int main()
{
    ll WH,HH,N;
    cin >> WH >> HH >> N;
    ll WL = 0;
    ll HL = 0;

    vector<vector<ll>> xy(N,vector<ll>(2));
    vector<ll> a(N);

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            cin >> xy.at(i).at(j);
        }
        cin >> a.at(i);
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            if(a.at(i) == 1)WL = max(WL,xy.at(i).at(0));
            if(a.at(i) == 2)WH = min(WH,xy.at(i).at(0));
            if(a.at(i) == 3)HL = max(HL,xy.at(i).at(1));
            if(a.at(i) == 4)HH = min(HH,xy.at(i).at(1));
        }
        
    }

    if(WH - WL <= 0 || HH - HL <= 0)cout << "0" << endl;
    else cout << (WH - WL) * (HH - HL) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    

    int H, W, sx, sy;
    cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
          cin >> s[i][j];
        }
    }
        
    int ans = 0;
    for(int m=0;m<H;m++){
      for(int n=0;n<W;n++){
        if(s[m][n] == '#') continue;
        sx = m;
        sy = n;
        int dist[25][25];
        fill((int*)dist, (int*)(dist + H), INF);
        queue<P> que;
        dist[sx][sy] = 0;
        que.push(P(sx, sy));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            int x = p.first;
            int y = p.second;
            
            for(int i = 0; i < 4; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
                if(s[nx][ny] == '#')    continue;
                
                if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push(P(nx, ny));
                    ans = max(ans, dist[nx][ny]);
                }
            }
        }
      }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())

minx = 0
maxx = W
miny = 0
maxy = H

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        maxy = min(maxy, y)

    ans = (maxx - minx) * (maxy - miny)

print(ans if minx < maxx and miny < maxy else 0)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int n, A[2000];

bool solve(int i, int m){
  if(m == 0){ return true; }
  if(i >= n){ return false; }
  bool res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}

int main(){
  int q, m;

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> A[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> m;
    if(solve(0, m)){ cout << "yes" << endl; }
    else{ cout << "no" << endl; }
  }

  return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int a, b;
	cin >> a >> b;
	cout << a*b << en;


	return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>

int main(){
	int max,n,i,result1,result;
	scanf("%d %d",&max,&n);
	for(i=0;i<n;i++){
		scanf("%d",&result1);
		result+=result1;
	}
	if(result>=max)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  rep(i, N) { cin >> a[i]; }
  rep(i, N) { cin >> b[i]; }
  rep(i, N) { cin >> c[i]; }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  rep(i, N) {
    int mid = b[i];
    ll low_cnt, high_cnt;

    // 下段の２分探索
    int l = -1, r = N;
    while (l + 1 < r) {
      int x = (l + r) / 2;
      if (mid > a[x]) {
        l = x;
      } else {
        r = x;
      }
    }
    low_cnt = r;

    // 上限の２分探索
    l = -1, r = N;
    while (l + 1 < r) {
      int x = (l + r) / 2;
      if (mid >= c[x]) {
        l = x;
      } else {
        r = x;
      }
    }
    high_cnt = N - r;

    ans += low_cnt * high_cnt;
    // printf("i:%d, l:%lld, r:%lld\n", i, low_cnt, high_cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
def main():
    D, G, *pc = map(int, open(0).read().split())
    p = pc[::2]
    c = pc[1::2]
    ans = 1e9 + 7
    # 2 ** D - 1 まで
    for b in range(2 ** D):
        num = 0
        pnt = 0
        # コンプリートしない MAX
        x = None
        # 得点が高い方から
        for i in range(D - 1, -1, -1):
            # i 番目 の フラグ が 立っている
            if b >> i & 1:
                num += p[i]
                # コンプリートする
                pnt += c[i] + 100 * (i + 1) * p[i]
            elif x is None:
                x = i
        # コンプリート オール
        # または 既に 目標の 総合スコア に到達
        if x is None or G <= pnt:
            ans = min(ans, num)
        # コンプリートしない MAX で 目標の 総合スコア に到達
        elif G < (100 * (x + 1)) * p[x] + pnt:
            ans = min(ans, num - (-(G - pnt) // (100 * (x + 1))))
    print(ans)
    return


main()


Measured memory_bytes: 3064