akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main (void){
	long int a, b, k;
	long int i;
	scanf("%ld %ld %ld", &a, &b, &k);
	
	if(a>=k){
		a=a-k;
	}
	else if (a<k && a+b >=k){
		k -= a;
		a = 0;
		b -= k;
	}else{
		a=0; b=0;
	}
	
	printf("%ld %ld", a, b);
}

Measured memory_bytes: 128
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        s = line.strip()
        ans = []
        L = len(s)
        i = 0
        while i < L:
            if s[i] == "@":
                k = int(s[i+1])
                i += 2
            else:
                k = 1
            c = s[i]
            ans.append(c*k)
            i += 1
        write("".join(ans))
        write("\n")
solve()



Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

ll po(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

ll f[2000006], g[2000006];

void comb() {
    f[0] = 1;
    for (int i = 1; i <= 2000000; i++) f[i] = f[i - 1] * i % mod;
    g[2000000] = 407182070;
    for (int i = 1999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
}

int p[200005];

int root(int x) {return p[x] < 0 ? x : p[x] = root(p[x]);}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {}, b[200005] = {}, e[200005] = {}, x[200005] = {}, y[200005] = {}, f = 0, g = 0, h[200005] = {};
    pii d[200005] = {}, z[200005] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], h[a[i]]++, d[a[i]].first++;
    for (int i = 0; i < n; i++) cin >> b[i], e[b[i]]++;
    for (int i = 1; i <= n; i++) d[i].second = i;
    sort(d + 1, d + n + 1);
    for (int i = n; i; i--) {
        if (d[i].first + e[d[i].second] > n) {
            cout << "No";
            return 0;
        }
        for (int j = f; j < min(n, f + d[i].first); j++) x[j] = d[i].second;
        f += d[i].first;
        for (int j = f; j < min(n, f + e[d[i].second]); j++) y[j] = d[i].second;
        f += e[d[i].second];
        if (f >= n) {
            g = d[i].second;
            break;
        }
    }
    multiset<int> s, t;
    for (int i = 0; i < n; i++) h[x[i]]--, e[y[i]]--;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < h[i]; j++) s.insert(i);
        for (int j = 0; j < e[i]; j++) t.insert(i);
    }
    for (int i = 0; i < n; i++) {
        if (!x[i]) {
            x[i] = *s.begin();
            s.erase(s.begin());
        }
        if (!y[i]) {
            if (e[g]) y[i] = g, e[g]--, t.erase(t.find(g));
            else y[i] = *t.begin(), t.erase(t.begin());
        }
    }
    for (int i = 0; i < n; i++) z[i].first = x[i], z[i].second = y[i];
    sort(z, z + n);
    cout << "Yes\n";
    for (int i = 0; i < n; i++) cout << z[i].second << ' ';
}


Measured memory_bytes: 20816
# 毎回計算しても間に合うんじゃね？N<=200000だしソート使っても余裕では
# と思ってたけど全然ダメでした
# ソートしたやつを使ってn/2かn/2+1かを判断する

n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
arr_sort = arr.sort
one, two = arr_sort[n/2-1], arr_sort[n/2]
arr.each do |ai|
  # sputs "{ai} vs {one}"
  if ai<=one
    puts two
  else
    puts one
  end
end

Measured memory_bytes: 27364
n,m=map(int,input().split())
w,u=3*m,n-1
o,f,i=998244353,[1],1
while i<w+n:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
a=c(w+u,u)-n*c(n+m-2,u)
while~-n>m<w:m+=2;a-=c(n,m)*c(2*u+w-m>>1,u)
print(a%o)

Measured memory_bytes: 115556
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
#include <cstdlib>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  int N, K, h, now;
  cin >> N >> K;
  int H[N], dp[N];
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    h = H[i];
    now = dp[i-1] + abs( h - H[i-1] );
    for (int j = max(i-K,0); j < i; ++j) {
      if (now > dp[j] + abs( h - H[j])){
        now = dp[j] + abs( h - H[j]);
      }
    }
    dp[i] = now;
  }
  cout << dp[N-1] << "\n";
  return 0;
}


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


bool check(int r, int c, std::vector<std::vector<int> >& boad)
{
	for (int j = 0; j < 8; j++)
	{	
		if (boad.at(r).at(j) == 1 || boad.at(j).at(c) == 1)
			return false;
	}
	int r1 = r - 1;
	int r2 = r - 1;
	int r3 = r + 1;
	int r4 = r + 1;
	int c1 = c - 1;
	int c2 = c + 1;
	int c3 = c - 1;
	int c4 = c + 1;
	while (r1 >= 0 && c1 >= 0)
	{	
		if (boad.at(r1).at(c1) == 1)
			return false;
		r1--;
		c1--;
	}
	while (r2 >= 0 && c2 <= 7)
	{
		if (boad.at(r2).at(c2) == 1)
			return false;
		r2--;
		c2++;
	}
	while (r3 <= 7 && c3 >= 0)
	{
		if (boad.at(r3).at(c3) == 1)
			return false;
		r3++;
		c3--;
	}
	while (r4 <= 7 && c4 <= 7)
	{
		if (boad.at(r4).at(c4) == 1)
			return false;
		r4++;
		c4++;
	}
	return true;
}


int main()
{
	int k;
	std::cin >> k;
	std::vector<std::pair<int, int> > QUEEN;
	std::vector<int> N;
	for (int i = 0; i < k; i++)
	{
		int r, c;
		std::cin >> r >> c;
		QUEEN.push_back(std::make_pair(r, c));
	}

	for (int i = 0; i < 8; i++)
		N.push_back(i);
	
	do
	{
		bool flag = true;
		std::vector<std::vector<int> > boad(8, std::vector<int> (8, 0));
		for (int i = 0; i < 8; i++)
		{
			if (!(check(i, N.at(i), boad)))
				flag = false;
			boad.at(i).at(N.at(i)) = 1;
		}
		if (flag)
		{
			for (int i = 0; i < k; i++)
			{
				if (boad.at(QUEEN.at(i).first).at(QUEEN.at(i).second) != 1)
					flag = false;
			}
		}
		if (flag)
		{	
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 8; j++)
				{
					char c;
					if (boad.at(i).at(j) == 0)
						c = '.';
					else
						c = 'Q';
					std::cout << c;
				}
				std::cout << '\n';
			}
			return 0;
		}
	} while (std::next_permutation(N.begin(), N.end())); 
}



Measured memory_bytes: 3140
#include <cmath>
#include <iostream>
using namespace std;
int n; double ax, ay, bx, by, cx, cy;
int main() {
	cin >> n;
	while (n--) {
		cin >> ax >> ay >> bx >> by >> cx >> cy;
		double a1 = 2 * (bx - ax);
		double b1 = 2 * (by - ay);
		double c1 = ax * ax - bx * bx + ay * ay - by * by;
		double a2 = 2 * (cx - ax);
		double b2 = 2 * (cy - ay);
		double c2 = ax * ax - cx * cx + ay * ay - cy * cy;
		double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		double r = hypot(ax - x, ay - y);
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

const int MAX_TIME = 721;
const int DIFF = 540;

struct Computer {
    vector<pair<int, int> > login;
    vector<pair<int, int> > logout;
};

struct Student {
    bool isUsing[MAX_TIME];
};

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        int r;
        cin >> r;
        vector<Computer> computers(n + 1);
        for (int i = 0; i < r; i++) {
            int t, pc, user, s;
            cin >> t >> pc >> user >> s;
            t -= DIFF;
            if (s) {
                computers[pc].login.push_back(make_pair(user, t));
            } else {
                computers[pc].logout.push_back(make_pair(user, t));
            }
        }
        vector<Student> students(m + 1);
        for (int i = 1; i <= m; i++) {
            memset(students[i].isUsing, 0, sizeof(students[i].isUsing));
            for (int j = 1; j <= n; j++) {
                for (int k = 0, size = computers[j].login.size(); k < size; k++) {
                    if (computers[j].login[k].first == i) {
                        fill(students[i].isUsing + computers[j].login[k].second, students[i].isUsing + computers[j].logout[k].second, true);
                    }
                }
            }
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++) {
            int start, end, user;
            cin >> start >> end >> user;
            start -= DIFF;
            end -= DIFF;
            int time = 0;
            for (int j = start; j < end; j++) {
                if (students[user].isUsing[j]) {
                    time++;
                }
            }
            cout << time << endl;
        }
    }
}

Measured memory_bytes: 7760
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

struct ETABLE{
	char cha;
	string code;
};

struct DTABLE{
	string code;
	char cha;
}; 

int main()
{
	const ETABLE s[] = {
{' ', "101"},
{'\'', "000000"},
{',', "000011"},
{'-', "10010001"},
{'.', "010001"},
{'?', "000001"},
{'A', "100101"},
{'B', "10011010"},
{'C', "0101"},
{'D', "0001"},
{'E', "110"},
{'F', "01001"},
{'G', "10011011"},
{'H', "010000"},
{'I', "0111"},
{'J', "10011000"},
{'K', "0110"},
{'L', "00100"},
{'M', "10011001"},
{'N', "10011110"},
{'O', "00101"},
{'P', "111"},
{'Q', "10011111"},
{'R', "1000"},
{'S', "00110"},
{'T', "00111"},
{'U', "10011100"},
{'V', "10011101"},
{'W', "000010"},
{'X', "10010010"},
{'Y', "10010011"},
{'Z', "10010000"}
};
	const DTABLE t[] = {
{"00000",'A'},
{"00001",'B'},
{"00010",'C'},
{"00011",'D'},
{"00100",'E'},
{"00101",'F'},
{"00110",'G'},
{"00111",'H'},
{"01000",'I'},
{"01001",'J'},
{"01010",'K'},
{"01011",'L'},
{"01100",'M'},
{"01101",'N'},
{"01110",'O'},
{"01111",'P'},
{"10000",'Q'},
{"10001",'R'},
{"10010",'S'},
{"10011",'T'},
{"10100",'U'},
{"10101",'V'},
{"10110",'W'},
{"10111",'X'},
{"11000",'Y'},
{"11001",'Z'},
{"11010",' '},
{"11011",'.'},
{"11100",','},
{"11101",'-'},
{"11110",'\''},
{"11111",'?'}
};

//	freopen("testcase.codedoctor", "r", stdin);
	string str = "";

	map <char, string > encode;
	map <string, char > decode;
	int i;

//	cout << "sizeof (code): " << sizeof (s)/sizeof (s[0]) << endl;

	for (i = 0; i < sizeof (s)/sizeof (s[0]); ++i){
		encode[s[i].cha] = s[i].code;
		decode[t[i].code] = t[i].cha;
	} // end for
/*
	map <char, string >::iterator it = encode.begin();
	for (; it != encode.end(); ++it ){
		cout << (*it).first << ':' << (*it).second << endl;
	} // end for

	map <string, char >::iterator it = decode.begin();
	for (; it != decode.end(); ++it ){
		cout << (*it).first << ':' << (*it).second << endl;
	} // end for
*/
	while (getline (cin, str ) ){
		string temp = "";
		int len = str.length();

		for (i = 0; i < len; ++i){
			char c = str[i];
			temp += encode[c];
		} // end for
		if (temp.length() % 5 != 0 ){
			temp += string (5 - temp.length() % 5, '0' );
		} // end if
		//cout << temp << endl;
		len = temp.length();

		for (i = 0; i < len; i += 5 ){
			string str = temp.substr (i, 5);
//			cout << "str: " << str << endl;
			cout << decode[str];
		} // end for
		cout << endl;		
		
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
const int INF=10000000;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
int main(){
  int h,w,n;cin>>h>>w>>n;
  map<int,int>mph,mpw;
  set<pair<int,int>>zahyou;
  rep(i,n){
    ll r,c;
    cin>>r>>c;
    zahyou.insert({r,c});
    mph[r]++;
    mpw[c]++;
  }
  int maxh=0,maxw=0;
  for(auto p:mph)chmax(maxh,p.second);
  for(auto p:mpw)chmax(maxw,p.second);
  vector<int>numh,numw;
  for(auto p:mph)if(p.second==maxh)numh.push_back(p.first);
  for(auto p:mpw)if(p.second==maxw)numw.push_back(p.first);
  rep(i,numh.size())rep(o,numw.size()){
    if(!zahyou.count({numh[i],numw[o]})){
      cout<<maxh+maxw<<endl;
      return 0;
    }
  }
  cout<<maxh+maxw-1<<endl;
}

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

long long dp[100005];


int v[105], w[105];

int main()
{
    int n,W;
    scanf("%d %d",&n,&W);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d %d",&w[i],&v[i]);
    }

    for(int j = 0; j <= 100000; j++)
    {
        dp[j] = 1e15;
    }   
    
    dp[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 100000; j >= v[i]; j--)
        {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }

    for(int i = 100000; i >= 0; i--)
    {
        if(dp[i] <= W)
        {
            printf("%d\n",i);
            return 0;
        }
    }



    return 0;
}

Measured memory_bytes: 1024
from fractions import gcd

def exist_good_str(N,M,S,T,L):
  X = {}
  for idx, s in enumerate(S):
    if idx != 0: idx = L//N*idx
    if idx in X and X[idx] != s: return False
    else: X[idx] = s
    
  for idx, t in enumerate(T):
    if idx != 0: idx = L//M*idx 
    if idx in X and X[idx] != t: return False
    else: X[idx] = t
  return True
      
N,M = map(int,input().split())
S,T = input(), input()

L = int((N * M / gcd(N, M)))
if exist_good_str(N,M,S,T,L) is True: print(L)
else: print(-1)

Measured memory_bytes: 83432
n = int(input())
s = input()

w = [0] * n
for i in range(n-1):
  w[i+1] = w[i] + int(s[i] == 'W')
    
    
e = [0] * n
for i in reversed(range(1, n)):
  e[i-1] = e[i] + int(s[i] == 'E')
    
print(min(ww+ee for ww, ee in zip(w, e)))

Measured memory_bytes: 27128
#include "bits/stdc++.h"
using namespace std;

const long long infinity = 1e18;

int w[100];
int v[100];

long long dp[100][100001];
// dp[index][value] = minimum weight

int main(){
	int n,W;
	cin>>n>>W;
	
	for(int i=0;i<100;i++){
		for(int j=0;j<=100000;j++){
			dp[i][j] = infinity;
		}
	}
	
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	
	for(int id=1;id<n;id++){
		dp[id][0] = 0;
		for(int j=1;j<=100000;j++){
			
			// Discard current object
			dp[id][j] = dp[id-1][j];
			
			// Pick current object
			if(j >= v[id])
				dp[id][j] = min(dp[id][j], w[id] + dp[id-1][j-v[id]]);
			
		}
	}
	
	long long answer;
	
	for(int val = 100000;val>=0;val--){
		if(dp[n-1][val] <= W){
			answer = val;
			break;
		}
	}
	
	cout<<answer;
	
	return 0;
}


Measured memory_bytes: 81648
import java.util.*;

public class Main{
	public  static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int N = scan.nextInt();
      	int a = N / 1000;
      	int b = N / 100 - 10 * a;
      	int c = N / 10 - 100 * a - 10 * b;
      	int d = N % 10;
      	if(a + b + c + d == 7){
         	System.out.print(a + "+" + b + "+" + c  + "+"  + d + "=7"); 
        }else if(a + b + c - d == 7){
         	System.out.print(a + "+" + b + "+" + c  + "-"  + d + "=7"); 
        }else if(a + b - c + d == 7){
         	System.out.print(a + "+" + b + "-" + c  + "+"  + d + "=7"); 
        }else if(a + b - c - d == 7){
         	System.out.print(a + "+" + b + "-" + c  + "-"  + d + "=7"); 
        }else if(a - b - c + d == 7){
         	System.out.print(a + "-" + b + "-" + c  + "+"  + d + "=7"); 
        }else if(a - b - c - d == 7){
         	System.out.print(a + "-" + b + "-" + c  + "-"  + d + "=7"); 
        }else if(a - b + c + d == 7){
         	System.out.print(a + "-" + b + "+" + c  + "+"  + d + "=7"); 
        }else if(a - b + c - d == 7){
         	System.out.print(a + "-" + b + "+" + c  + "-"  + d + "=7"); 
        }
    
    }

}

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

int main() {
  long long N; cin >> N;
  long long X[N];
  for (int i = 0; i < N; i++) cin >> X[i];
  
  long long min_ = 1000000000000;
  for (long long i = 0; i <= 100; i++){
    long long count = 0;
    for (long long j = 0; j < N; j++){
      count += (X[j] - i) * (X[j] - i);
    }
    min_ = min(min_, count);
  }
  cout << min_ << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);
  int cns=0;
  int DX, DY,DH;
  for(int i=0; i<N; i++){
    cin >> x.at(i) >> y.at(i) >> h.at(i);
    if(h.at(i)==0) cns++;
    else{
      DX=x.at(i);
      DY=y.at(i);
      DH=h.at(i);
    }
  }
  int CX, CY, H;
  for(int i=0; i<=100; i++){
    for(int j=0; j<=100; j++){
      int cnt=0;
      int ha=0;
      for(int k=0; k<N; k++){
        if(h.at(k)==0){
          cnt++;
          continue;
        }
        int hb=h.at(k)+abs(x.at(k)-i)+abs(y.at(k)-j);
        if(ha==hb) cnt++;
        ha=hb;
      }
      if(cnt==N-1){
        CX=i;
        CY=j;
        H=ha;
        break;
      }
    }
  }
  if(cns==N-1){
    CX=DX;
    CY=DY;
    H=DH;
  }
  cout << CX << ' ' << CY << ' ' << H << endl;
}

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

class Point {
public:
  double x, y;
  Point(double x=0, double y=0) : x(x), y(y) {}
  Point operator -(Point p) {
    return Point(x-p.x, y-p.y);
  }
};
typedef Point Vector;

double cross(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}
Point p[3];
Point q;

bool solve() {
  int dir;
  double tmp;
  for(int i = 0; i < 3; i++) {
    int a = i;
    int b = (i+1)%3;

    tmp = cross(p[b]-p[a], q-p[a]);
    if(i == 0) {
      if(tmp > 0) dir = 1;
      else        dir = -1;
    } else {
      switch(dir) {
      case 1:
	if(!(tmp > 0)) return false;
	break;
      case -1:
	if(!(tmp < 0)) return false;
	break;
      }
    }
  }
  return true;
}

int main() {
  bool loop = true;
  while(1) {
    for(int i = 0; i < 3; i++) {
      cin >> p[i].x >> p[i].y;
      if(cin.eof()) {
	loop = false;
	break;
      }
    }
    if(!loop) break;
    cin >> q.x >> q.y;

    if(solve()) cout << "YES" << endl;
    else        cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static string S;

void solve(void) {
  sl N = S.size();
  sl res = 0;
  FOR0(i, N / 2) {
    if (S[N - i - 1] != S[i]) {
      res++;
    }
  }
  cout << res << endl;
}

int main(void) {
  cin >> S;
  solve();
  return 0;
}

Measured memory_bytes: 256
A,B,C = (int(i) for i in input().split())
K = int(input())

for i in range(K):
    maxnum = max(A,B,C)
    if maxnum == A:
        A = maxnum
        A = 2*A
    elif maxnum == B:
        B = maxnum
        B = 2*B
    else:
        C = maxnum
        C = 2*C

print(A+B+C)

Measured memory_bytes: 3060
#C
n = int(input())

f = [0 for _ in range(10**5)]

for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            f[i**2 + j**2 + k**2 + i*j + j*k + k*i] += 1

for l in range(n):
    print(f[l+1])

Measured memory_bytes: 9760
r,t,x=map(int,input().split())
a=r*x-t
b=r*a-t
c=r*b-t
d=r*c-t
e=r*d-t
f=r*e-t
g=r*f-t
h=r*g-t
i=r*h-t
j=r*i-t
print(a)
print(b)
print(c)
print(d)
print(e)
print(f)
print(g)
print(h)
print(i)
print(j)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
void show(int a[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i>0) putchar(' ');
        printf("%d",a[i]);
    }
    putchar('\n');
}
void insertionsort(int a[],int n)
{
    int t,i,j;
    for(i=1;i<n;i++)
    {
        t=a[i];
        j=i-1;
        while(j>=0&&a[j]>t)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=t;
        show(a,n);
    }
}

int main()
{
    int a[101],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    show(a,n);
    insertionsort(a,n);
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define x first
#define y second
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const long long mod = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
int tx[800005],ty[800005],lx[800005],ly[800005];
int n,Q;

void pushX(int x,int l,int r) {
	tx[x] = min(tx[x],lx[x]);
	if(l ^ r) {
		lx[x*2] = min(lx[x*2],lx[x]);
		lx[x*2+1] = min(lx[x*2+1],lx[x]);
	}
	lx[x] = INF;
}

void pushY(int x,int l,int r) {
	ty[x] = min(ty[x],ly[x]);
	if(l ^ r) {
		ly[x*2] = min(ly[x*2],ly[x]);
		ly[x*2+1] = min(ly[x*2+1],ly[x]);
	}
	ly[x] = INF;
}

void updateX(int x,int l,int r,int rl,int rr,int val) {
	if(rl > rr) return;
	pushX(x,l,r);
	if(rl > r||l > rr) return;
	if(rl <= l&&r <= rr) {
		lx[x] = min(lx[x],val); pushX(x,l,r);
		return;
	}
	int mid = (l + r) >> 1;
	updateX(x*2,l,mid,rl,rr,val), updateX(x*2+1,mid+1,r,rl,rr,val);
	tx[x] = min(tx[x*2],tx[x*2+1]);
}

void updateY(int x,int l,int r,int rl,int rr,int val) {
	if(rl > rr) return;
	pushY(x,l,r);
	if(rl > r||l > rr) return;
	if(rl <= l&&r <= rr) {
		ly[x] = val; pushY(x,l,r);
		return;
	}
	int mid = (l + r) >> 1;
	updateY(x*2,l,mid,rl,rr,val), updateY(x*2+1,mid+1,r,rl,rr,val);
	ty[x] = min(ty[x*2],ty[x*2+1]);
}

void build(int x,int l,int r) {
	tx[x] = ty[x] = lx[x] = ly[x] = n;
	if(l == r) return;
	int mid = (l + r) >> 1;
	build(x*2,l,mid), build(x*2+1,mid+1,r);
}

int queryX(int x,int l,int r,int wi) {
	pushX(x,l,r);
	if(wi < l||r < wi) return n;
	if(l == r) return tx[x];
	int mid = (l + r) >> 1;
	return min(queryX(x*2,l,mid,wi),queryX(x*2+1,mid+1,r,wi));
}

int queryY(int x,int l,int r,int wi) {
	pushY(x,l,r);
	if(wi < l||r < wi) return n;
	if(l == r) return ty[x];
	int mid = (l + r) >> 1;
	return min(queryY(x*2,l,mid,wi),queryY(x*2+1,mid+1,r,wi));
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> Q;
	ll ans = 1LL*(n-2)*(n-2);
	build(1,1,n);
	for(int i = 1;i <= Q;i++) {
		int op,x; cin >> op >> x;
		if(op & 1) {
			int tmp = queryY(1,1,n,x);
			ans -= max(0,tmp-2);
			updateX(1,1,n,1,tmp-1,x);
		}
		else {
			int tmp = queryX(1,1,n,x);
			ans -= max(0,tmp-2);
			updateY(1,1,n,1,tmp-1,x);
		}
	}
	cout << ans;
 	return 0;
}

Measured memory_bytes: 11840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int i = Integer.parseInt(str);
		if(i == 3) {
			System.out.println("YES");
		}else if(i==5){
			System.out.println("YES");
		}else if(i ==7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		sc.close();
	}

}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	ll a[n+1], s[n+1], m[n+1];
	for(int i=1; i<=n; i++) cin >> a[i];
	s[0]=0, m[0]=0;
	for(int i=1; i<=n; i++){
		s[i]=s[i-1]+a[i];
		m[i]=m[i-1]+max(0ll, a[i]);
	}

	ll ans=0;
	for(int i=1; i+k<=n+1; i++){
		ll tmp=max(0ll, s[i+k-1]-s[i-1])+m[i-1]+(m[n]-m[i+k-1]);
		ans=max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

int main(){
    int n;
    cin >> n;
    printf("%.10f\n", (n%2) == 0? 1.0/2.0 :(double) (n / 2 +1) / (double)(n));
}
/*
    Good Luck
        -Lucina
*/


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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = w * h / 2;
    bool many = w / 2 == x && h / 2 == y;

    printf("%f %d\n", ans, many);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
//#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define INF (long long)102000000000000
#define NAX (int)1e2+2
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		char c;
		cin>>c;
		char a = ++c;
		cout<<a;
		
	}
};
	  
int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
    int flag=0;
    string S;
  cin >> S;
  vector<int> N(26,0);
  for(int i=0;i<S.length();i++){
    N.at(S.at(i)-97)++;
    if(N.at(S.at(i)-97)==2){
        flag=1;
        break;
    }
  }
  if(flag==1)cout << "no" << endl;
  else cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	string s;
	cin >> s;
	cout << (char)(s[0]);
	cout << (ll)(s.size() - 2);
	cout<<(char)(s[s.size() - 1]) << endl;
	
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string b;
  cin>>b;
  if (b == "A") {
    cout << "T";
  } else if (b == "T") {
    cout << "A";
  } else if (b == "C") {
    cout << "G";
  } else {
    cout << "C";
  }
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
ln = len(bin(a[-1])) - 2
bit = [[0,0] for i in range(ln)]
res = 0
for i in a:
    for j in range(ln):
        tmp = 0
        if (i>>j) % 2:
            tmp += 1
        bit[j][tmp] += 1
for i,j in enumerate(bit):
    c = pow(2,i)
    res += j[0] * j[1] * c
    res %= mod
print(res)

Measured memory_bytes: 127084
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007

long long func(int p){
    long long a=1;
    if(p==0) return 1;
    for(int i=1;i<=p;i++) a=((a%mod)*(2%mod))%mod;
    return a;
}

int main(){
    long long i,j,n;
    long long xr;
    long long ara[3000001];//try adding 0 on ara limit or use vector
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%lld",&ara[i]);

    for(i=0,xr=0;i<60;i++){
        long long zc=0,ac=0;
        long long isum=0;
        for(j=0;j<n;j++){
            if(ara[j]%2==0) zc++;
            else ac++;
            ara[j]=ara[j]/2;
        }
        isum=((zc%mod)*(ac%mod))%mod;
        isum=((isum%mod)*(func(i)%mod))%mod;
        xr=((xr%mod)+(isum%mod))%mod;
    }
    printf("%lld\n",xr);


return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){ans *=(n+1-j); ans /= j; ans %= MOD;} }return ans;}
template<typename T> T gcd(T a, T b){if(b == 0) return a;else return gcd(b, a%b);}
template<typename T> T lcm(T a, T b){if(b > a) swap(a, b); T g = gcd(a, b);return a / g * b;}

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

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


Measured memory_bytes: 3716
cardset_S=[i for i in range(1,14)]
cardset_H=[i for i in range(1,14)]
cardset_C=[i for i in range(1,14)]
cardset_D=[i for i in range(1,14)]

card_num=int(input())
for i in range(card_num):
    card=input().split()
    if card[0]=='S':
        cardset_S.remove(int(card[1]))
    elif card[0]=='H':
        cardset_H.remove(int(card[1]))
    elif card[0]=='C':
        cardset_C.remove(int(card[1]))
    else:
        cardset_D.remove(int(card[1]))
for i in cardset_S:
    print('S {}'.format(i))
for i in cardset_H:
    print('H {}'.format(i))
for i in cardset_C:
    print('C {}'.format(i))
for i in cardset_D:
    print('D {}'.format(i))
    


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int ans = 0;
    rep(i, k) ans+= l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <numeric>

using namespace std;

int indt[100005];

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		indt[num]++;
		sum += num;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int b, c;
		cin >> b >> c;
		indt[c] += indt[b];
		sum += (c - b) * (long long)indt[b];
		indt[b] = 0;
		cout << sum << endl;
	}


	return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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

// agc070
int main(){
	int N;cin>>N;
	vector<ll> t(N);
	REP(i,N)cin>>t[i];

	ll ans = 1;

	REP(i,N){
		ans *= t[i]/gcd(t[i],ans);
	}

	cout << ans << endl;

	return 0;
}




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

const int kNmax = 1e5 + 10;
const int kInf = numeric_limits<int>::max();

int k, sum[kNmax];
priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;

int main() {
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
        sum[i] = kInf;
    }
    
    pq.push({0, 0});
    while (!pq.empty()) {
        int cost = pq.top().first;
        int rest = pq.top().second;
        
        pq.pop();
        for (int d = 0; d < 10; d++) {
            int next_rest = (rest * 10 + d) % k;
            if (next_rest == 0 && cost + d == 0) {
                continue;
            }
            if (sum[next_rest] > cost + d) {
                sum[next_rest] = cost + d;
                pq.push({sum[next_rest], next_rest});
            }
        }
    }
    
    printf("%d\n", sum[0]);
}

Measured memory_bytes: 2804
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>

#define ll long long int
using namespace std;
ll calc(ll n)
{
	ll sum = 7, st = 10;
	for(int i = 0; i < 1000000; i++)
	{
		if(sum % n == 0)
			return i + 1;
		sum = sum * 10;
		sum %= n;
		sum += 7;
		sum %= n;
	}
	return -1;
}
int main()
{
    ll k;
    cin>>k;
    cout<<calc(k)<<endl;
    return 0;
}


Measured memory_bytes: 3592
n = gets.strip.to_i

case Math.log10(n).floor+1
when 1 
  p n
when 2
  p 9
when 3
  p (1..n).count - 90
when 4
  p 909
when 5
  p (1..n).count - 9090
when 6
  p 90909
end


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

using namespace std;

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

	vector<int> point(n, k - q);
	for (int i = 0; i < q; i++)
	{
		int a;
		cin >> a;
		point.at(a - 1)++;
	}

	for (int i = 0; i < n; i++)
	{
		if (0 < point.at(i))
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#include <limits.h>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 1000000007;

//UnionFind 
struct UnionFind
{
    std::vector<ll> uni;
    ll num;
    UnionFind(ll s) : uni(s, -1),num(s) {}

    //頂点aが所属するグループ
    ll root(ll a)
    {
        if (uni[a] < 0)
        {
            return a;
        }
        return uni[a] = root(uni[a]);
    }

    //a,bをつなげる
    bool connect(ll a, ll b)
    {
        a = root(a);
        b = root(b);
        if (a == b)
        {
            return false;
        }

        if (uni[a] > uni[b])
        {
            std::swap(a, b);
        }

        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    //a,bが同グループか確認
    bool isConnect(ll a, ll b)
    {
        return root(a) == root(b);
    }

    //aが属するグループの要素数
    ll size(ll a)
    {
        return -uni[root(a)];
    }

    //グループ数を返す
    ll groups()
    {
        std::set<ll> b;
        for (ll i = 0; i < num; i++)
        {
            b.insert(root(i));
        }
        return b.size();
    }
};

struct Edge{ll u,v,cost;};

bool comp(const Edge& e1,const Edge& e2){
    return e1.cost<e2.cost;
}

ll krustal(ll n,std::vector<Edge>& es){
    sort(all(es),comp);
    UnionFind path(n);
    ll res=0,e=es.size();
    rep(i,0,e){
        Edge temp=es[i];
        if(!path.isConnect(temp.u,temp.v)){
            path.connect(temp.u,temp.v);
            res+=temp.cost;
        }
    }
    return res;
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    //問題文中の添え字が0-indexか1-indexか確認!

    ll n;
    std::cin >> n;
    std::vector<P> x(n), y(n);
    std::vector<Edge> es;
    rep(i,0,n){
        ll a, b;
        std::cin >> a >> b;
        x[i] = P(a, i);
        y[i] = P(b, i);
    }
    sort(all(x));
    sort(all(y));
    rep(i,1,n){
        es.push_back(Edge{x[i].second,x[i-1].second,x[i].first-x[i-1].first});
        es.push_back(Edge{y[i].second,y[i-1].second,y[i].first-y[i-1].first});
    }

    std::cout<<krustal(n,es);
    return 0;
}

Measured memory_bytes: 11632
#include <iostream>

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;

  int i = 0;
  string a;
  
  while(N != 0){
    a[i] = N%K;
    N /= K;
    i++;
  }

  cout << i << endl;  

  return 0;
}


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

const int MAX_N = 8, MAX_M = MAX_N * (MAX_N - 1) / 2;

int N, M, a[MAX_M], b[MAX_M];

vector<int> graph[MAX_N];
bool used[MAX_N];

int dfs(int n) {
	used[n] = true;
	
	bool end = true;
	for (int i = 0; i < N; i++) {
		end &= used[i];
	}
	if (end) {
		used[n] = false;
		return 1;
	}

	int res = 0;
	for (int i = 0; i < graph[n].size(); i++) {
		if (!used[graph[n][i]]) {
			res += dfs(graph[n][i]);
		}
	}
	
	used[n] = false;
	return res;
}

void solve() {
	for (int i = 0; i < M; i++) {
		graph[a[i] - 1].push_back(b[i] - 1);
		graph[b[i] - 1].push_back(a[i] - 1);
	}

	memset(used, false, sizeof(used));

	int res = dfs(0);
	printf("%d\n", res);
}

int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &a[i], &b[i]);
	}

	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>    //super header :標準ライブラリ,STLを全てインクルード
using namespace std;


int main(){
    int a[3] = {};cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);

    int ans;
    if((a[0]-a[1])&1){
        ans =  ((a[2]-a[1]) + (a[2]-a[0]) + 1)/2 + 1;
    }else{
        ans =  ((a[2]-a[1]) + (a[2]-a[0]))/2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
array = gets.chomp.split("").map(&:to_i)

if array[0] + array[1] + array[2] + array[3] == 7
  print "#{array[0]}+#{array[1]}+#{array[2]}+#{array[3]}=7"
elsif array[0] + array[1] + array[2] - array[3] == 7
  print "#{array[0]}+#{array[1]}+#{array[2]}-#{array[3]}=7"
elsif array[0] + array[1] - array[2] + array[3] == 7
  print "#{array[0]}+#{array[1]}-#{array[2]}+#{array[3]}=7"
elsif array[0] - array[1] + array[2] + array[3] == 7
  print "#{array[0]}-#{array[1]}+#{array[2]}+#{array[3]}=7"
elsif array[0] + array[1] - array[2] - array[3] == 7
  print "#{array[0]}+#{array[1]}-#{array[2]}-#{array[3]}=7"
elsif array[0] - array[1] + array[2] - array[3] == 7
  print "#{array[0]}-#{array[1]}+#{array[2]}-#{array[3]}=7"
elsif array[0] - array[1] - array[2] + array[3] == 7
  print "#{array[0]}-#{array[1]}-#{array[2]}+#{array[3]}=7"
elsif array[0] - array[1] - array[2] - array[3] == 7
  print "#{array[0]}-#{array[1]}-#{array[2]}-#{array[3]}=7"
end


Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int maxn = 1005;
char sl[maxn][maxn];
const int mod = 1e9 + 7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
    int h, w;
    scanf("%d%d", &h, &w);
    for(int i = 0; i < h; i++) {
        scanf("%s", sl[i]);
    }
    int dp[h][w];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int row = 0; row < h; ++row) {
        for(int col = 0; col < w; ++col) {
            for(int r2 : {row, row + 1}) {
                int c2 = col;
                if(r2 == row) {
                    c2 = col + 1;
                }
                if(r2 < h && c2 < w && sl[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[row][col]);
                }
            }
        }
    }
    printf("%d\n", dp[h-1][w-1]);
}

Measured memory_bytes: 8680
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int i = 1;
		int n = s.nextInt();
		int x;
		int a = 0;
		x = i;
		while(a>=0){
			switch(a){
				case 0:
					a = -1;
					x = i;
					if(x % 3 == 0){
						System.out.print(" " + i);
						break;
					}
				case 1:
					if(a == 1){
						a = -1;
					}
					if(x % 10 == 3){
						System.out.print(" " + i);
						break;
					}
					x /= 10;
					if(x!=0){
						a = 1;
					}
			}
			if(a!=1){
			i++;
			if(i <= n){
				a = 0;
			}
			}
		}
		System.out.print("\n");
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
}
/*
3 6 9 12 13 15 18 21 23 24 27 30 33 36 39 42 43 45 48 51 53 54 57 60
3 6 9 12 13 15 18 21 23 24 27 30 31 32 33 34 35 36 37 38 39 42 43 45 48 51 53 54 57 60
*/

Measured memory_bytes: 28412
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        # O(n_max + log(mod))
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % mod
            fac.append(f)
        f = pow(f, mod-2, mod)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    # "n 要素" は区別できる n 要素
    # "k グループ" はちょうど k グループ

    def __call__(self, n, r):  # self.C と同じ
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def C(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def P(self, n, r):
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[n-r] % self.mod

    def H(self, n, r):
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

    def rising_factorial(self, n, r):  # 上昇階乗冪 n * (n+1) * ... * (n+r-1)
        return self.fac[n+r-1] * self.facinv[n-1] % self.mod

    def stirling_first(self, n, k):  # 第 1 種スターリング数  lru_cache を使うと O(nk)  # n 要素を k 個の巡回列に分割する場合の数
        if n == k: return 1
        if k == 0: return 0
        return (self.stirling_first(n-1, k-1) + (n-1)*self.stirling_first(n-1, k)) % self.mod

    def stirling_second(self, n, k):  # 第 2 種スターリング数 O(k + log(n))  # n 要素を区別のない k グループに分割する場合の数
        if n == k: return 1  # n==k==0 のときのため
        return self.facinv[k] * sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def balls_and_boxes_3(self, n, k):  # n 要素を区別のある k グループに分割する場合の数  O(k + log(n))
        return sum((-1)**(k-m) * self.C(k, m) * pow(m, n, self.mod) for m in range(1, k+1)) % self.mod

    def bernoulli(self, n):  # ベルヌーイ数  lru_cache を使うと O(n**2 * log(mod))
        if n == 0: return 1
        if n % 2 and n >= 3: return 0  # 高速化
        return (- pow(n+1, self.mod-2, self.mod) * sum(self.C(n+1, k) * self.bernoulli(k) % self.mod for k in range(n))) % self.mod

    def faulhaber(self, k, n):  # べき乗和 0^k + 1^k + ... + (n-1)^k
        # bernoulli に lru_cache を使うと O(k**2 * log(mod))  bernoulli が計算済みなら O(k * log(mod))
        return pow(k+1, self.mod-2, self.mod) * sum(self.C(k+1, j) * self.bernoulli(j) % self.mod * pow(n, k-j+1, self.mod) % self.mod for j in range(k+1)) % self.mod

    def lah(self, n, k):  # n 要素を k 個の空でない順序付き集合に分割する場合の数  O(1)
        return self.C(n-1, k-1) * self.fac[n] % self.mod * self.facinv[k] % self.mod

    def bell(self, n, k):  # n 要素を k グループ以下に分割する場合の数  O(k**2 + k*log(mod))
        return sum(self.stirling_second(n, j) for j in range(1, k+1)) % self.mod

ans = 0
mod = 10**9+7
K = int(input())
S = input()
comb = Combination(2020202)
N = len(S)
for i in range(K+1):
    a = comb(N+K-1-i, N-1)
    a = a * pow(25, K-i, mod) % mod * pow(26, i, mod) % mod
    ans += a
print(ans % mod)


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

using namespace std;

const int MaxN = 502;

long long a[MaxN][MaxN];

vector <int> p1;
vector <int> p2;

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

bool isPrime(int x)
{
    if(x == 1)
        return false;
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

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

void build(int x, int y)
{
    for(int i = 0; i < 4; ++i)
    {
        int xx = x + dx[i];
        int yy = y + dy[i];

        if(xx >= 0 && xx < MaxN && yy >= 0 && yy < MaxN)
            a[x][y] = lcm(a[x][y], a[xx][yy]);
    }

    ++a[x][y];

    assert(a[x][y] <= 1e15 && a[x][y] > 0);
}

void check()
{
    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
        {
            for(int d = 0; d < 4; ++d)
            {
                int x = i + dx[d];
                int y = j + dy[d];

                if(x >= 0 && x < MaxN && y >= 0 && y < MaxN)
                {
                    long long k1 = min(a[i][j], a[x][y]);
                    long long k2 = max(a[i][j], a[x][y]);

                    assert(k2 % k1 == 1);
                }
            }
        }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    mt19937 rnd(clock());

    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            a[i][j] = 1;

    for(int i = 2; i <= 20000; ++i)
        if(isPrime(i))
        {
            if(p1.size() <= MaxN)
                p1.push_back(i);
            else
                p2.push_back(i);
        }

//    shuffle(p1.begin(), p1.end(), rnd);
//    shuffle(p2.begin(), p2.end(), rnd);

   for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j + i < MaxN; ++j)
            a[i + j][j] *= p1[i];

    for(int j = 2; j < MaxN; j += 2)
        for(int i = 0; i + j < MaxN; ++i)
            a[i][j + i] *= p1[j - 1];



    for(int i = 0; i < MaxN; i += 2)
        for(int j = 0; j < MaxN && i - j >= 0; ++j)
            a[i - j][j] *= p2[i];



    for(int j = 2 - !(MaxN & 1); j < MaxN; j += 2)
        for(int i = 0; j + i < MaxN; ++i)
            a[MaxN - 1 - i][j + i] *= p2[j + !(MaxN & 1) - 1];


  /*  for(int i = 0; i < MaxN; ++i)
    {
        for(int j = 0; j < MaxN; ++j)
            cout << a[i][j] << ' ';
        cout << '\n';
    }*/



    for(int i = 0; i < MaxN; ++i)
        for(int j = 0; j < MaxN; ++j)
            if((i + j) & 1)
                build(i, j);


    check();

    int n;
    cin >> n;

    assert(n <= MaxN);

    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
            cout << a[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 4992