akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;

  vector<int> v;
  ll now = n+1;
  while(now>1) {
    if(now%2==0) now /= 2, v.push_back(0);
    else now--, v.push_back(1);
  }
  reverse(ALL(v));

  deque<int> ans;
  REP(i, v.size()) {
    if(v[i]==0) ans.push_back(i+1);
    else ans.push_front(i+1);
  }

  cout << ans.size() * 2 << endl;
  REP(i, ans.size()) cout << i+1 << " ";
  for(auto i: ans) cout << i << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int digitSum(long a)
{
	int reval=0;
	int i = 0;
	while (a >= 1){
		reval += a % 10;
		a /= 10;
	}
	return reval;
}
int Harshad(long N)
{
	int reval;
	if ((N%digitSum(N)) == 0) reval = 1;
	else reval = 0;
	return reval;
}
int main()
{
	long N;
	scanf("%ld", &N);
	if (Harshad(N)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            if ((4*h*n - N*h - N*n) <= 0) continue;
            if ((N*h*n) % (4*h*n - N*h - N*n) != 0) continue;
            ll w = (N*h*n) / (4*h*n - N*h - N*n);
            if (w > 0) {
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}


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

using namespace std;

int main() {
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0&&m==0)break;
        vector<pair<int,int>> mas(n,{0,0}),mis(n,{0,0});
        for(int i=0;i<n;i++){
            mas[i].second=i;
            mis[i].second=i;
        }
        for(int i=0;i<m;i++){
            int s,k;
            cin >> s >> k;
            if(k==1){
                int t;
                cin >> t;
                t--;
                mas[t].first+=s;
                mis[t].first+=s;
            }else{
                for(int j=0;j<k;j++) {
                    int t;
                    cin >> t;
                    t--;
                    mas[t].first += s;
                }
            }
        }
        sort(mis.begin(),mis.end());
        sort(mas.begin(),mas.end());
        int ans=mas.back().first-mis[0].first+1;
        if(mas.back().second==mis[0].second){
            int t1=mas.back().first-mis[1].first+1;
            int t2=mas[mas.size()-2].first-mis[0].first+1;
            ans=max(t1,t2);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3216
c=[]
s=[]
f=[]

N = 506

for i in range(N) :
    c.append(0)
    s.append(0)
    f.append(0)
n=int(input())
for i in range(1,n) :
    c[i],s[i],f[i] = map(int,input().split())
    
for i in range(1,n) :
    now = s[i] + c[i]
    for j in range(i+1,n) :
        if now >= s[j] :
            now = ((now + f[j] - 1)//f[j] )*f[j]
            now += c[j]
        else :
            now = s[j]
            now += c[j]
    print(now)

print(0)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const auto MOD = 1000000007;
//sort(all(x))とするとソートできるよ

//壊れた階段を０と設定し、n-1 n-2 段目までの到達数を足し合わせる。

vector<LL> L;

int DFS(int i){
    if(i == 0)return L[i] = 1;
    if(i == 1 && L[1] != 0)return L[1] = 1;

    if(L[i] != -1)return L[i]; //メモ化再帰

    return L[i] = (DFS(i-1) + DFS(i-2)) % MOD;
}


int main(){
    int N,M;
    cin >> N >> M;
    L.assign(N+1,-1);
    int a;
    rep(i,M){
        cin >> a;L[a] = 0;
    }
    cout << DFS(N) << endl;

}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E;
  
  int k = min(min(min(min(A,B),C),D),E);
  int ans = (N+k-1)/k+4;

  
  cout << ans << endl;
  
}


Measured memory_bytes: 3588
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // aの読み込み
    let a: i32 = iter.next().unwrap().parse().unwrap();
    // bの読み込み
    let b: i32 = iter.next().unwrap().parse().unwrap();

    // ans
    let ans: i32 = cmp::max(a + b, cmp::max(a - b, a * b));

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

Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int a,b,i,j,k;
    scanf("%d",&a);
    int x[a][6];
    for(i=0;i<a;i++){
        for(j=0;j<6;j++){
            scanf("%d",&x[i][j]);
        }
    }
 
    for(i=0;i<a-1;i++){
        for(j=i+1;j<a;j++){
            for(k=0;k<122;k++){
                if(x[i][0]==x[j][0]&&x[i][5]==x[j][5]){
                    if(x[i][1]==x[j][1]&&x[i][4]==x[j][4]){
                        if(x[i][2]==x[j][2]&&x[i][3]==x[j][3]){
                            puts("No");
                            return 0;
                        }
                    }
                    else{
                        b=x[j][1];x[j][1]=x[j][2];x[j][2]=x[j][4];
                        x[j][4]=x[j][3];x[j][3]=b;
                    }
                }
                if(k%2){
                    b=x[j][1];x[j][1]=x[j][0];x[j][0]=x[j][4];
                    x[j][4]=x[j][5];x[j][5]=b;
                }
                else{
                    b=x[j][5];x[j][5]=x[j][2];x[j][2]=x[j][0];
                    x[j][0]=x[j][3];x[j][3]=b;
                }
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 580
#include <cstdio>

int w, h;
int c[50][50];

void dfs(int a, int b){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			int A = a+i-1, B = b+j-1;
			if(0<=A&&A<w&&0<=B&&B<h&&c[A][B]){
				c[A][B] = 0;
				dfs(A,B);
			}
		}
	}
}

int main(){
	while(scanf("%d%d", &w, &h),w||h){
		int ans = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				scanf("%d", &c[j][i]);
			}
		}
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				if(c[i][j]){
					c[i][j] = 0;
					ans++;
					dfs(i,j);
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1216
import numpy

H, W, K = map(int, input().split())

data = []
for i in range(H):
    data.append(list(map(lambda x: int(x == "#"), input())))

data = numpy.asarray(data)

result = 0
for i in range(2**H):
    # bitが0なら未選択
    H_matrix = numpy.asarray([int(bool(i & (1 << h))) for h in range(H)])

    for j in range(2**W):
        W_matrix = numpy.asarray([int(bool(j & (1 << w))) for w in range(W)])
        if numpy.sum((data * W_matrix).T * H_matrix) == K:
            result += 1

print(result)

Measured memory_bytes: 26948
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,c;
	while(1){
		cin>>a>>b>>c;
		if(a==-1&&b==-1&&c==-1)		break;
		int x=a+b;
		if(a==-1&&b>=0||a>=0&&b==-1){
			cout<<"F"<<endl;
		}
		else{
				if(x>=80){
				cout<<"A"<<endl;
			}
			else if(80>x&&x>=65){
				cout<<"B"<<endl;
			}
			else if(65>x&&x>=50){
				cout<<"C"<<endl;
			}
			else if(50>x&&x>=30){
				if(c>=50){
					cout<<"C"<<endl;
				}
				else{
					cout<<"D"<<endl;
				}
			}
			else{
				cout<<"F"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
  int i, j, key, n, array[100];

  scanf("%d", &n);

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

  for (i = 0; i < n; i++) {
    key = array[i];
    j = i - 1;
    while (j >= 0 && array[j] > key) {
      array[j + 1] = array[j];
      j--;
    }
    array[j + 1] = key;

    for (j = 0; j < n; j++) {
      printf("%d%c", array[j], j == n - 1 ? '\n' : ' ');
    }
  }

  return 0;
}

Measured memory_bytes: 600
from itertools import count

K = int(input())
f = lambda x: (x*10+7)%K

a = 7%K
b = 7%K


for t in count(1):
    if a == 0:
        print(t)
        break
    if t > 1 and a == b:
        print(-1)
        break
    a = f(a)
    b = f(f(b))

Measured memory_bytes: 67444
#include <stdio.h>

int main(void){
	int a,b;
  	scanf("%d", &a);
  	scanf("%d", &b);
  
  	int ans = 0;
  ans = a*b;
  
  if(ans%2 == 0){
	printf("Even");
  }else{
   printf("Odd"); 
  }
return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

typedef pair<int,int> P;

vector<P> G[100];
int s,d;
bool v[100];

int prim(void){
  int res = 0;
  for(int i=0;i<=s+d;i++)v[i] = false;
  v[0] = v[s+d] = true;
  priority_queue<P,vector<P>,greater<P> > q;
  
  for(int i=0;i<(int)G[0].size();i++){
    P next = G[0][i];
    if(v[next.second])continue;
    q.push(next);
  }

  for(int i=0;i<(int)G[s+d].size();i++){
    P next = G[s+d][i];
    if(v[next.second])continue;
    q.push(next);
  }
  
  while(q.size()){
    P p = q.top(); q.pop();
    int now = p.second;    

    if(v[now])continue;
    v[now] = true;
    res += p.first;

    for(int i=0;i<(int)G[now].size();i++){
      P next = G[now][i];
      if(v[next.second])continue;
      q.push(next);
    }
  }

  return res;
}

int main(){
  while(cin >> s >> d, s||d){
    for(int i=0;i<=s+d;i++)G[i].clear();

    int tmp;
    for(int i=0;i<s;i++)
      for(int j=0;j<d;j++){
	cin >> tmp;
	if(!tmp)tmp = 100000000;
	G[i].push_back(P(tmp,s+j));
	G[s+j].push_back(P(tmp,i));
      }
    
    for(int i=0;i<d;i++)
      for(int j=i+1;j<d;j++){
	cin >> tmp;
	if(!tmp)tmp = 100000000;
	G[s+i].push_back(P(tmp,s+j));
	G[s+j].push_back(P(tmp,s+i));
      }

    for(int i=0;i<s;i++){
      G[s+d].push_back(P(0,i));
    }

    cout << prim() << endl;
  }
}

Measured memory_bytes: 0
(let ((x (read))
    (ans 0))
    (setq ans (* (floor (/ x 11)) 2))
    (setq x (rem x 11))
    (if (>= x 7)
        (incf ans 2)
        (if (not (= x 0))
            (incf ans)
        )
    )
    (princ ans)
)

Measured memory_bytes: 24412
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N, X;
	cin >> N >> X;
	vint L(N), ans;

	int tmp = 0;
	int p = 0;

	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	ans.push_back(0);
	for (int i = 0; i < N; i++) {
		tmp += L[i];
		ans.push_back(tmp);
	}

	for (int i = 0; i < ans.size(); i++) {
		if (ans[i] <= X) {
			p++;
		}
	}

	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    double a,b;
    cin >> a >> b;
    double ans = (a+b)/2 + 0.9;
    OUT((int)ans);
}


Measured memory_bytes: 256
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        long ans = 0;
        int now = 0;
        for (int i = 0; i < N; i++) {
            if (i == 0 && A[i] != 0) {
                System.out.println(-1);
                return;
            }
            if (A[i] == now+1) {
                ans++;
                now++;
            } else if (A[i] <= now) {
                ans += A[i];
                now = A[i];
            } else {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 81692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 100000;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <ll M = MOD> struct modint {
    ll val;
    modint(const ll x = 0) : val(x) {
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
    }

    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint operator/(const modint a) const { return modint(*this) /= a; }
    modint operator-() const { return modint(M-val); }
    modint inv() const {
        ll u = 1, v = 0, s = 0, t = 1, m = M, x = val;
        while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
        if(s < 0) s += M;
        return modint(s);
    }
    modint pow(ll n) const {
        ll u = 1, xx = val;
        while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; }
        return modint(u);
    }
    modint& operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; }
    modint& operator-=(const modint a){ val -= a.val; if(val < 0) val += M; return *this; }
    modint& operator*=(const modint a){ val = val * a.val % M; return *this; }
    modint& operator/=(const modint a){ val = val * a.inv().val % M; return *this;}

    modint& operator=(const int& x){
        val = x;
        while(val < 0) val += M;
        while(val > M) val -= M;
        return *this;
    }
};

using mint = modint<MOD>;

int main() {
    int n, m, s;
    while(cin >> n >> m >> s, n){
        vector<vector<mint>> dp(n*n+1, vector<mint>(s+1, 0));
        dp[0][0] = 1;
        for (int i = 1; i <= n*n; ++i) {
            for (int j = i; j <= s; ++j) {
                dp[i][j] = dp[i][j-i] + dp[i-1][j-i];
                if(j >= m+1) dp[i][j] -= dp[i-1][j-(m+1)];
            }
        }
        cout << dp[n*n][s].val << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 4048
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

ll cost[1005];
ll weight[1005];

ll dp[20505];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll h,n;
    cin>>h>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>weight[i]>>cost[i];
    }
    for(ll i=0;i<20505;i++)
    {
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(ll i=1;i<20505;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if((i-weight[j])>=0)
            {
                dp[i]=min(dp[i],dp[i-weight[j]]+cost[j]);
            }
        }
    }
    ll ans=INT_MAX;
    for(ll i=h;i<20505;i++)
    {
        ans=min(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}


//252908XL

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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

unsigned euclidean_lcm(unsigned a, unsigned b) {
	unsigned g;
	g = euclidean_gcd(a, b);
	return a*b/g;
}

int main() {
	long long n = 0;
	double mother, child = 0;
	cin >> n;
	vector<double> a(n);
	vector<double> b(n);
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	for (long long j = 1; j < n; j++) {
		a[j] = euclidean_lcm(a[j], a[j-1]);
		mother = a[j]; //最小公倍数
	}
	for (int k = 0; k < n; k++) {
		child += mother/b[k]; //最小公倍数÷配列[i] 
	}
	cout << setprecision(12) << mother/child << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;

/////////////////////////////////////////////////////////

void Main(){
  int A, B, C; cin >> A >> B >> C;
  int cnt = 0;
  if(A % 2 == B % 2 && A % 2 != C % 2){
    A++; B++; cnt++;
  }
  else if(B % 2 == C % 2 && B % 2 != A % 2){
    B++; C++; cnt++;
  }
  else if(C % 2 == A % 2 && C % 2 != B % 2){
    C++; A++; cnt++;
  }
  if(A == max({A, B, C})){
    cnt += (A - B) / 2;
    cnt += (A - C) / 2;
  }
  else if(B == max({A, B, C})){
    cnt += (B - C) / 2;
    cnt += (B - A) / 2;
  }
  else if(C == max({A, B, C})){
    cnt += (C - A) / 2;
    cnt += (C - B) / 2;
  }
  out(cnt)
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
import math

a, b, C = [int(i) for i in input().strip().split()]

S = (a * b * math.sin(C * (math.pi / 180))) / 2
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b *
                      math.cos(C * (math.pi / 180)))
h = 2 * S / a

print(S, L, h)


Measured memory_bytes: 5720
#include <stdio.h>
int main(void)
{
  int tate[100];
  int yoko[100];
  int a=0;
  int i=0;
  int j,l;

  for (;;) {
	scanf("%d%d",&tate[i],&yoko[i]);
	if (tate[i]==0 && yoko[i]==0) break;
	a++;
	i++;
  }

  for (i=0; i<a; i++) {
	for (j=0; j<tate[i]; j++) {
	  for (l=0; l<yoko[i]; l++) {
		if ((j+l)%2==0) printf("#");
		else printf(".");
	  }
	  printf("\n");
	}
	printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
// Problem: 
// 			F - Intervals on Tree
// 			Editorial
// 		
// Contest: AtCoder - AtCoder Beginner Contest 173
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

void Solve(){
  int n;
  LL ans=0;
  cin>>n;
  rep(i,1,n)ans+=(LL)(n-i+1)*i;
  rep(i,1,n-1){
    int u,v;
    cin>>u>>v;
    if(u>v)swap(u,v);
    ans-=(LL)(u)*(n-v+1);
  }
  cout<<ans<<endl;
} 


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

int main()
{
	int N;
	cin >> N;
	vector<double> x( N );
	vector<double> y( N );
	for( int i = 0; i < N; i++ ) {
		cin >> x[i] >> y[i];
	}

	vector<int> r( N );
	for( int i = 0; i < N; i++ ) r[i] = i;
	double ans = 0;
	int n = 0;
	do {
		for( int i = 0; i < N - 1; i++ ) {
			double xx = x[ r[i] ] - x[ r[i + 1] ];
			double yy = y[ r[i] ] - y[ r[i + 1] ];
			ans += sqrt( xx * xx + yy * yy );
		}
		n++;
	} while( next_permutation( r.begin(), r.end() ) );
	ans /= n;

	cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

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

const ll inf=100000000000000000;

priority_queue<int> q;

struct node
{
	int x,y,z;
	bool operator <(const node &a)const {return y-z>a.y-a.z;}
}a[100010];

ll b[100010],c[100010];

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int x,y,z;scanf("%d%d%d",&x,&y,&z);
	for (int i=1;i<=x+y+z;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
	sort(a+1,a+x+y+z+1);
    while (!q.empty()) q.pop();
    ll s=0;
    for (int i=1;i<=y;i++) {q.push(a[i].x-a[i].y);s+=a[i].y-a[i].x;}
    b[y]=s;
    for (int i=y+1;i<=x+y+z;i++)
    {
    	int t=a[i].x-a[i].y;
    	if (t<=q.top())
    	{
    		s=s+q.top()-t;
    		q.pop();q.push(t);
    	}
    	b[i]=s;
    }
    while (!q.empty()) q.pop();
    for (int i=1;i<=(x+y+z)/2;i++) swap(a[i],a[x+y+z+1-i]);
    s=0;
	for (int i=1;i<=z;i++) {q.push(a[i].x-a[i].z);s+=a[i].z-a[i].x;}
    c[z]=s;
	for (int i=z+1;i<=x+y+z;i++)
    {
    	int t=a[i].x-a[i].z;
    	if (t<=q.top())
    	{
    		s=s+q.top()-t;
    		q.pop();q.push(t);
    	}
    	c[i]=s;
    }
    ll ans=-inf;
    for (int i=y;i<=x+y;i++) ans=max(ans,b[i]+c[x+y+z-i]);
    for (int i=1;i<=x+y+z;i++) ans+=a[i].x;
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;

class Main {
    public static void main(String [] args){
    	
        Scanner scan = new Scanner(System.in);
        
        int m = 0;
        int f = 0;
        int r = 0;
        
        while(true){
        	
        	m = scan.nextInt();//中間テスト点数
            f = scan.nextInt();//期末テスト点数
            r = scan.nextInt();//再試験点数
        	
	        if(m==-1 && f==-1 && r==-1){
	        	break;
	    	}else if(m==-1 || f==-1){
	    		System.out.println("F");
	    	}else if ( m+f >= 80){
	        	System.out.println("A");
	        }else if(65 <= m+f && m+f < 80){
	        	System.out.println("B");
	        }else if(50 <= m+f && m+f < 65){
	        	System.out.println("C");
	        }else if(30 <= m+f && m+f < 50){
	        	if(r >= 50){
	        		System.out.println("C");
	        	}else{
	        		System.out.println("D");
	        	}
	        }else{
	        	System.out.println("F");
	        }
        
        }
        
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1),b(n);
    F(n+1) cin >> a[i];
    F(n) cin >> b[i];
    long sum=0;
    F(n){
        if(a[i]>=b[i]){
            sum += b[i];
        }
        else{
            sum += a[i];
            b[i] -= a[i];
            if(a[i+1]>=b[i]){
                sum += b[i];
                a[i+1]-=b[i];
            }
            else{
                sum += a[i+1];
                a[i+1]=0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
s = set()
e = set()
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        s.add(b)
    elif b == n:
        e.add(a)

if len(s & e) >= 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 19024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

string N;
int K;
ll dp[101][2][101];

ll rec(string &S, int k = 0, bool tight = true, int state = 0) {
  if (k == S.size()) {
    if (state == K)
      return 1;
    else
      return 0;
  }

  if (dp[k][tight][state] != -1)
    return dp[k][tight][state];

  int x = S[k] - '0';
  int r = tight ? x : 9;
  ll res = 0;
  rep(i, 0, r + 1) {
    int st = i == 0 ? state : state + 1;
    res += rec(S, k + 1, tight && i == r, st);
  }

  return dp[k][tight][state] = res;
}

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

  cin >> N >> K;
  memset(dp, -1, sizeof(dp));
  ll ans = rec(N);
  cout << ans << endl;
}


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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 100100
#define NMAX 
#define MMAX 

using namespace std;

int n, k, a[DMAX], total;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	a[n + 1] = a[0] = 0;

	for(int i = 1; i <= n + 1; i++) {
		total += fabs(a[i] - a[i - 1]);
	}

	for(int i = 1; i <= n; i++) {
		// i - 1 ... i ... i + 1
		// i - 1 .. .... i + 1
		int ans = total;
		ans -= fabs(a[i] - a[i - 1]) + fabs(a[i + 1] - a[i]);
		ans += fabs(a[i + 1] - a[i - 1]);
		cout << ans << '\n';
	}

} 	

Measured memory_bytes: 1664
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

from collections import defaultdict

n, t = getMN()
nums = getlist()
ans = defaultdict(int)
cur = nums[0]
upper = cur
profits = defaultdict(int)
n_low = 1
n_up = 1

for num in nums[1:]:
    if cur > num:
        profits[upper-cur] += min(n_low, n_up)
        cur = num
        n_low = 1
        n_up = 1
        upper = cur
    elif cur == num:
        n_low += 1
    elif num == upper:
        n_up += 1
    elif num > upper:
        upper = num
        n_up = 1
profits[upper-cur] += min(n_low, n_up)

maxkey = max(profits.keys())
print(profits[maxkey])

Measured memory_bytes: 14628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s,t;
	cin >> s >> t;
	int l=s.size();
	int m=0;
	for(int i=0; i<l; i++){
		if(s[i]!=t[i])
			m++;
	}
	cout << m;


	
	

	return 0;
}

Measured memory_bytes: 3912
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
from collections import Counter
from fractions import Fraction

def resolve():
    n = int(input())
    zero = 0
    counter = Counter()
    for _ in range(n):
        x, y = map(int, input().split())
        if x == 0 and y == 0:
            zero += 1
            continue

        g = gcd(x, y)
        x //= g
        y //= g

        if x == 0:
            x, y = 0, 1
        elif x < 0:
            x, y = -x, -y
        counter[x, y] += 1

    C = list(counter.items())
    C.sort(key = lambda p: Fraction(p[0][1], p[0][0]) if p[0][0] != 0 else -float("inf"))

    k = len(C)
    dp = [0] * (k + 1)
    dp[0] = 1
    for i in range(k):
        x, y = C[i][0]
        dp[i + 1] += dp[i]
        dp[i + 1] += (pow(2, counter[x, y], MOD) - 1) * dp[i] * pow(2, -counter[y, -x] % (MOD - 1), MOD)
        dp[i + 1] %= MOD

    res = dp[k]
    res -= 1
    res += zero
    print(res % MOD)
resolve()

Measured memory_bytes: 155412
from collections import Counter
from itertools import product, permutations
def main():
    n, c = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(c)]
    C = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n)]

    group = [Counter([C[i][j] for i,j in product(range(n), range(n)) if (i+j+2) %3 == k]) for k in range(3)] 
    
    ans = float('inf')
    for color in permutations(range(c), 3):
        diff = 0
        for i in range(3):
            diff += sum(D[before_color][color[i]]*count for before_color, count in group[i].items())
        ans = min(ans, diff)
    print(ans)

main()

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

int main() {

	string s; cin>>s;
	vector<int>ans(s.size());
	int acum = 0;
	for(int i = 0; i<s.size()-1; i++){
		if(s[i] == 'R' and s[i+1] == 'L'){
			ans[i]++;
			ans[i+1]++;
			ans[i]+= acum/2;
			ans[i+1] += (acum + 1)/2;
			acum = 0;
		}
		
		if(s[i] == 'R') acum++;
		if(s[i] == 'L') acum = 0;
	}
	
	acum = 0;
	
	for(int i = s.size()-1; i>0; i--){
		if(s[i] == 'L' and s[i-1] == 'R'){
			ans[i] += acum/2;
			ans[i-1] += (acum + 1)/2;
			acum = 0;
		}
		
		if(s[i] == 'L') acum++;
		
		if(s[i] == 'R') acum = 0;
	}
	
	for(int i = 0; i<ans.size(); i++) cout<<ans[i]<<" ";
	
	cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

typedef long long ll;
typedef struct {
	char t, d;
} Query;

ll n, q;
char grid[200005];
Query query[200005];
char buff[200005];

//初期位置を引数に取り、最終的位置を返す。n + 1のとき右に落ち、0のとき左に落ちる
ll simulate(ll position);
ll bin_search(char mode);

//VSのscanf()使わせてくれないやつ嫌い！！
ll input(const char* format, ...);

int main()
{
	ll left, right;

	input("%lld %lld", &n, &q);
	input("%s", grid + 1);
	for (ll i = 0; i < q; i++) {
		input("%c %c", &query[i].t, &query[i].d);
	}

	//printf("%lld : %lld\n", bin_search('L'), bin_search('R'));
	printf("%lld\n", bin_search('R') - bin_search('L') - 1);

	return EXIT_SUCCESS;
}

ll simulate(ll position)
{
	ll i = 0;
	while (i < q && position >= 1 && position <= n) {
		if (query[i].t == grid[position]) {
			if (query[i].d == 'L') {
				position--;
			}
			else if (query[i].d == 'R') {
				position++;
			}
		}

		i++;
	}

	return position;
}

ll bin_search(char mode)
{
	ll valid, invalid;
	ll mid;

	valid = (mode == 'L' ? 0 : n + 1);
	invalid = (mode == 'L' ? n + 1: 0);

	while (llabs(invalid - valid) > 1) {
		mid = (invalid + valid) / 2;

		if (simulate(mid) == (mode == 'L' ? 0 : n + 1)) {
			valid = mid;
		}
		else {
			invalid = mid;
		}
	}

	return valid;
}

ll input(const char* format, ...)
{
	va_list args;
	ll ret_val;

	fgets(buff, sizeof(buff) - 1, stdin);

	va_start(args, format);
	ret_val = vsscanf(buff, format, args);
	va_end(args);

	return ret_val;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,m,a,b,ans;
vector<int>v[100001];
vector<int>depth(100001,0);
vector<int>color(100001,0);
int dfs(int p)
{
	color[p]=1;
	for(auto u:v[p])
	{
		if(color[u]==1)
		{
			depth[p]=max(depth[p],depth[u]+1);
		}
		else
		{
			depth[p]=max(depth[p],dfs(u)+1);
		}
	}
	return depth[p];
}

main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		v[a].push_back(b);
	}
	for(int i=1;i<=n;i++)
	{
		dfs(i);
	}
	for(int i=1;i<=n;i++)
	{
		//cout<<depth[i]<<"\n";
		ans=max(ans,depth[i]);
	}
	cout<<ans;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)

ll powmod(ll n, ll k) {
    ll res = 1;
    while(k) {
        if(k&1) res = res*n%MOD;
        n = n*n%MOD;
        k /= 2;
    }
    return res;
}

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

    int n; cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a; cin >> a;
        mp[a]++;
    }
    
    if(n&1) {
        for(auto e : mp) {
            if(e.first&1) {
                cout << 0 << '\n';
                return 0;
            }
            if((e.first == 0 && e.second != 1) || (e.first != 0 && e.second != 2)) {
                cout << 0 << '\n';
                return 0;
            }
        }
        cout << powmod(2, (ll)mp.size()-1) << '\n';
    } else {
        for(auto e : mp) {
            if(e.first%2 == 0) {
                cout << 0 << '\n';
                return 0;
            }
            if(e.second != 2) {
                cout << 0 << '\n';
                return 0;
            }
        }
        cout << powmod(2, (ll)mp.size()) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>

int ketua[100010], ketinggian[100010];

int cari(int a) {
	return ((ketua[a] == a) ? a : cari(ketua[a]));
}

bool sameset(int b, int c) {
	return (cari(b) == cari(c));
}

void join(int d, int e) {
	int x = cari(d);
	int y = cari(e);
	if (ketinggian[x] > ketinggian[y])
		ketua[y] = x;
	else {
		ketua[x] = y;
		if (ketinggian[x] == ketinggian[y])
			ketinggian[y]++;
	}
}

int main() {
	int n, m, u, v, w, ans = 0;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		ketua[i] = i;
		ketinggian[i] = 0;
	}
	while (m--) {
		scanf("%d %d %d", &u, &v, &w);
		if (!sameset(u, v))
			join(u, v);
	}
	for (int i = 1; i <= n; i++)
		if (ketua[i] == i)
			ans++;
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector< int > a(n + 1), A(n + 1);
    vector< int > b(n), B(n);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
        A[i] = a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        B[i] = b[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += min(a[i], b[i]);
        if (a[i] > b[i]) {
            a[i] -= b[i];
            b[i] = 0;
        } else {
            b[i] -= a[i];
            a[i] = 0;
        }
        ans += min(a[i + 1], b[i]);
        if (a[i + 1] > b[i]) {
            a[i + 1] -= b[i];
            b[i] = 0;
        } else {
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }
    }
    long long ANS = 0;
    for (int i = n - 1; i >= 0; i--) {
        ANS += min(A[i + 1], B[i]);
        if (A[i + 1] > B[i]) {
            A[i + 1] -= B[i];
            B[i] = 0;
        } else {
            B[i] -= A[i + 1];
            A[i + 1] = 0;
        }
        ANS += min(A[i], B[i]);
        if (A[i] > B[i]) {
            A[i] -= B[i];
            B[i] = 0;
        } else {
            B[i] -= A[i];
            A[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
string str;
char ini[3];
int main() {
	for (int i = 0;i < 3;i++) {
		cin >> str;
		ini[i] = str[0]-32;
	}
	for (int i = 0;i < 3;i++) {
		cout << ini[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, F;
typedef pair<string, string> P;
P mp(string x, string y) {
  if (x > y) swap(x, y);
  return P(x, y);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> F;
  map<P, int> ctr;
  rep(i, N) {
    int m;
    cin >> m;
    vector<string> vs;
    rep(j, m) {
      string buf;
      cin >> buf;
      for (string &s : vs) ctr[mp(s, buf)]++;
      vs.pb(buf);
    }
  }
  vector<P> ans;
  for (auto p : ctr) {
    if (p._2 >= F) ans.pb(p._1);
  }
  assert(is_sorted(all(ans)));
  cout << ans.size() << "\n";
  for (auto p : ans) cout << p._1<< " " <<p._2<<"\n";
  return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string s;
	cin >> s;
	string ans = "CODEFESTIVAL2016";
	int cnt = 0;
	for (int i = 0; i < ans.size(); ++i)
	{
		if (s[i] != ans[i])
		{
			++cnt;
		}
	}
	cout << cnt << endl;
}

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

Measured memory_bytes: 256
num = int(input())
trump = []
data = []
for x in range(0,num):
    trump = input().split()
    if trump[0][0] == 'S':
        data.append(int(trump[1]))
    elif trump[0][0] == 'H':
        data.append(int(trump[1])+13)
    elif trump[0][0] == 'C':
        data.append(int(trump[1])+26)
    else :
        data.append(int(trump[1])+39)
for x in range(1,53):
    if x in data:
        pass
    else:
        if x < 14:
            print('S',x)
        elif x < 27:
            print('H',x-13)
        elif x < 40:
            print('C',x-26)
        else :
            print('D',x-39)


Measured memory_bytes: 7692
#include <stdio.h>

int main(){
  int a,b,c=1;
  int i=0;
  scanf("%d %d",&a,&b);
  
  if(b==1){
  	 printf("0\n");
     return 0;
  }
  do{
  	c += (a-1);
    i++;
  }while(c<b);

  printf("%d\n",i);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int s = 0;
    rep(i, k) s += a[i];
    cout << s << endl;
    return 0;
}

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

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

int s(int x) {
	int ret=0;
	while(x)
		ret+=x%10, x/=10;
	return ret;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout << (n%s(n)==0 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
mod=10**9+7
X=[int(i) for i in input().split()]
Y=[int(i) for i in input().split()]
X.sort()
Y.sort()
x,y=0,0
for i in range(1,n):
  x+=(X[i]-X[i-1])*i*(n-i)%mod
for i in range(1,m):
  y+=(Y[i]-Y[i-1])*i*(m-i)%mod
print(x*y%mod)

Measured memory_bytes: 19648
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []

for i in range(m):
    P, X = map(int, input().split())
    p.append(P)
    x.append(X)

for i in range(m):
    ans = sum(t) - t[p[i] - 1] + x[i]
    print(ans)

Measured memory_bytes: 3064
N = int(input())
As = list(map(int, input().split()))
d = dict()
def encode(i,j,k):
    return i+j*(N+1)+k*((N+1)**2)
def decode(x):
    return [(x // ((N+1)**i))%(N+1) for  i in range(3)]
B = 0
for a in As:
    B += (N+1)**(a-1)
d[0] = 0
for k in range(N+1):
    for j in range(N+1-k):
        for i in range(N+1-k-j):
            E = 0
            x = encode(i,j,k)
            s0 = N-i-j-k
            if i:
                E += (i*N)/((N-s0)**2) + d[x-1]*(i/(N-s0))
            if j:
                E += (j*N)/((N-s0)**2) + d[x-N]*(j/(N-s0))
            if k:
                E += (k*N)/((N-s0)**2) + d[x-N**2-N]*(k/(N-s0))
            d[x] = E
print(d[B])


Measured memory_bytes: 411376
#include <iostream>
using namespace std;
int main() {
    int a,b;
    int c,d,e;
    cin >> a >> b ;
    c = a+b;
    d = a-b;
    e = a*b;
    int middle = c > d ? c:d;
    int result = middle > e ? middle : e;
    cout << result<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

int H,W;
scanf("%d%d",&H,&W);

char C[H][W];

for (int i = 0; i < H; i++){
  for (int j = 0; j < W; j++){
    scanf(" %c",&C[i][j]);
  }
}

for (int i = 1; i <= 2*H; i++){
  int s=(i-1)/2;
  for (int j = 0; j < W; j++){
    printf("%c",C[s][j]);
  }
  puts("");
}

return 0;

}

Measured memory_bytes: 1604
#include<iostream>
#include<stdio.h>
int n,a[50];
int solve(int i,int m)
{
    if(m==0)return 1;
    if(i>=n)return 0;
    int res=solve(i+1,m)||solve(i+1,m-a[i]);
    return res;
}
int main()
{
    int q,m,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
    }
}

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(x[0] * x[1] + " " + (x[0] + x[1]) * 2); 
        }
    }
}



Measured memory_bytes: 16332
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<bool> isForbidden(10, false);
    rep(i, k)
    {
        int d;
        cin >> d;
        isForbidden[d] = true;
    }

    vector<int> available;
    rep(i, 10)
    {
        if (!isForbidden[i]) {
            available.push_back(i);
        }
    }

    int m = 1;
    while (m <= n)
        m *= 10;

    int s = 0;
    for (int r = 1; r <= n; r *= 10) {
        int d = (n / r) % 10;
        if (isForbidden[d]) {
            s = r;
        }
    }

    if (s == 0) {
        cout << n << endl;
    } else {
        int q;
        for (int r = s; r <= m; r *= 10) {
            int d = (n / r) % 10;
            auto p = lower_bound(available.begin(), available.end(), d + 1);
            if (p != available.end()) {
                q = r;
                break;
            }
        }
        //cout << "m=" << m << endl;
        //cout << "q=" << q << endl;

        int result = 0;
        for (int r = m; r > 0; r /= 10) {
            int d;
            if (r > q) {
                d = (n / r) % 10;
            } else if (r < q) {
                d = available[0];
            } else {
                d = *lower_bound(available.begin(), available.end(), (n / r) % 10 + 1);
            }
            result = 10 * result + d;
        }
        cout << result << endl;
    }

    return 0;
}

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

int main(void)
{
    int a, b;
    char s[20];
    int i, f = 0;

    scanf("%d %d", &a, &b);
    scanf("%s", s);
    
    for(i = 0; i < a; i++){
        if(s[i] < '0' || s[i] > '9') f++;
    }
    if(s[i] != '-') f++;
    for(i++; i < a+b+1; i++){
        if(s[i] < '0' || s[i] > '9') f++;
    }
    if(i != strlen(s))f++;
    
    if(f == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 128