akhauriyash/Code-Regression huggingface dataset:
public partial class IntroductionToProgramming{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int i = int.Parse(line[0]);
		int j = int.Parse(line[1]);

		int[,] a = new int[i, j];
		int[] b = new int[j];

		// ??????A?????????
		for (int k = 0; k < i; k++)
		{
			string[] line2 = System.Console.ReadLine().Split(' ');
			for (int l = 0; l < j; l++)
			{
				a[k, l] = int.Parse(line2[l]);
			}
		}
		// ??????B?????????
		for (int m = 0; m < j; m++)
		{
			b[m] = int.Parse(System.Console.ReadLine());
		}
		// ????????????C??????????????????
		for (int n = 0; n < i; n++)
		{
			int c = 0;
			for (int o = 0; o < j; o++)
			{
				c += a[n, o] * b[o];
			}
			System.Console.WriteLine(c.ToString());
		}
	}
}

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    //1の数を数える
    string num;
    int count=0;
    
    cin >> num;   
    
    for(int i; i<3; i++){
        if(num[i]=='1'){
            count++;
        }
    }
    
    cout << count << endl;
    
     return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, i = -1;
	cin>>n;
	if(n < 4 && n != 0)
	{cout<<"No\n";return 0;}
	if(n == 4)
{
	cout<<"Yes\n";
	return 0;
}
	for(i = 0; i < 15; i++)
{
	int a = i * 7;
	if(n < a)
{
	i = 15;
	break;
}
	a = n - a;
	if(a % 4 == 0)
	{cout<<"Yes\n";break;}
}
	if(i == 15)
	cout<<"No\n";
}

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

int main(){
    int N, A[100000];
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    int odd = 0;
    for(int i=0; i<N; i++) if(A[i] < 0){
        odd++;
        A[i] *= -1;
    }

    sort(A, A+N);
    if(odd % 2 == 1) A[0] *= -1;

    int64_t ans = 0;
    for(int i=0; i<N; i++) ans += A[i];
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = L_INF;
    for (ll a = -100; a <= 100; a++) {
        ll t = accumulate(A.begin(), A.end(), 0, [&](ll x, ll y) {
            return x + (y - a) * (y - a);
        });
        ans = min(ans, t);
    }

    cout << ans << "\n";

    return 0;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        String s=fsc.next();
        fsc.close();
        if(s.equals("SUN")) System.out.println(7);
        if(s.equals("MON")) System.out.println(6);
        if(s.equals("TUE")) System.out.println(5);
        if(s.equals("WED")) System.out.println(4);
        if(s.equals("THU")) System.out.println(3);
        if(s.equals("FRI")) System.out.println(2);
        if(s.equals("SAT")) System.out.println(1);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int W, a, b; cin >> W >> a >> b;
  int result = max(0, abs(a-b)-W);
  cout << result << endl;
  return 0;
}

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

 //bool dp[2][4000001];

signed main(){
    int n;
    cin >>n;
    int a[n],sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    bitset<4000001> dp2;
    dp2.set(0);
   
    //for(int j=0;j<=sum/2;j++)dp[0][j]=false;
    //dp[0][0]=true;
    //dp[0][a[0]]=true;
    //for(int i=0;i<n;i++)for(int j=0;j<=sum/2 ;j++)cerr <<dp[i][j]<<' ';
   // cerr <<endl;
    //for(int i=1;i<n;i++){
    //    for(int j=0;j<a[i];j++)dp[i%2][j]=dp[(i+1)%2][j];
    //    for(int j=a[i];j<=sum/2 ;j++)dp[i%2][j]=(dp[(i+1)%2][j-a[i]]||dp[(i+1)%2][j]);
    //}
        
    //int k=sum/2;
  //  for(int i=0;i<n;i++)for(int j=0;j<=sum/2 ;j++)cerr <<dp[i][j]<<' ';
    //cerr <<sum<<' ';
    //while(k>=0&&dp[(n-1)%2][k]==0)k--;
    //cerr <<k<<' ';
    //cout << sum-k;
    for(int i=0;i<n;i++){
        dp2 |= (dp2<<a[i]);
    }
    int k=(sum+1)/2;
    while(!dp2[k])k++;
    cout <<k;
    

    return 0;
}

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

#define ll long long int
#define db double
#define fl float
#define endl '\n'

#define mod (ll)(1000000007)
#define mod1 (ll)998242353
#define mod2 (ll)998244353
#define PI 3.1415926535897932384626433832795

#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pob pop_back

#define Sort(v) sort(v.begin(),v.end())
#define Sortd(v) sort(v.begin(),v.end(),greater<>())

#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;--i)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repn(i,a,b) for(int i=a;i<=b;++i)

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    

    


    return 0;
}



Measured memory_bytes: 3640
S=gets.chomp

state = 0
acount = 0
ret = 0

S.each_char do |c|
#  p [c, state, acount,ret]
  case state
  when 0
    if c == 'A'
      acount += 1
      state = 1
    else
      acount = 0
    end
  when 1
    if c == 'A'
      acount += 1
    elsif c == 'B'
      state = 2
    else
      acount = 0
      state = 0
    end
  when 2
    if c == 'A'
      acount = 1
      state = 1
    elsif c == 'C'
      ret += acount
      state = 1
    else
      acount = 0
      state = 0
    end
  end
end

p ret


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

int main() {
  int N, M, X, cnt;
  cin >> N >> M >> X;
  vector<int> money(N);
  vector<vector<int>> data(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> money.at(i);
    for (int j = 0; j < M; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  int answer = 10000000;
  
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<12> s(tmp);  
 
    vector<int> sum(M);

    for (int i = 0; i < M ; i++) {
      for (int j = 0; j < N; j++) {
        if (s.test(j)) {
          sum.at(i) += data.at(j).at(i);
        }
      }
    }
    
    bool check = true;  
    for(int i = 0; i < M; i++){
      if(sum.at(i)<X){
        check = false;
        break;
      }
    }
    if(check){
      int fee = 0;
      for(int i = 0; i < N; i++){
        if(s.test(i)){
          fee += money.at(i);
        }
      }
      answer = min(answer,fee);
    }
  }
  if(answer==10000000){
    cout <<-1;
  }
  else{
    cout << answer;
  }
}



Measured memory_bytes: 3624
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;

int main(){
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    if (s == "Cloudy") cout << "Rainy" << endl;
    if (s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

if __name__ == "__main__":
    n = int(input())
    mean = 0
    numbers = defaultdict(int)
    for i in map(int, input().split()):
        numbers[i] += 1
        mean += i
    mean = round(mean / n)
    res = 0
    for number in numbers:
        res += numbers[number] * (mean - number) ** 2

    print(res)


Measured memory_bytes: 3316
# AOTコンパイルテスト
import sys


def solve(n):
    su = 0
    for i in range(1, n+1):
        m = n//i
        su += m*(2*i + (m-1)*i)//2
    return su


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8)')(solve)
    cc.compile()
    exit()

n = int(input())
print(solve(n))

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

namespace ABC114_C
{
    class Program
    {
        const int Digits = 9;

        static int AddNumber(int[] numbers753, ref int index, int digits, int number, int _357Index, int[] _357eachCount)
        {
            ++digits;
            if (digits >= Digits)
            {
                return number;
            }

            int[] _357eachCount_ = new int[3];
            _357eachCount_[0] = _357eachCount[0];
            _357eachCount_[1] = _357eachCount[1];
            _357eachCount_[2] = _357eachCount[2];

            int _357 = 0;
            switch(_357Index)
            {
                case 0: _357 = 3; break;
                case 1: _357 = 5; break;
                case 2: _357 = 7; break;
            }

            number += (int)Math.Pow(10, digits) * _357;

            ++_357eachCount_[_357Index];

            if (_357eachCount_[0] >= 1 && _357eachCount_[1] >= 1 && _357eachCount_[2] >= 1)
            {
                numbers753[index] = number;

                ++index;
            }

            return Add753(numbers753, ref index, digits, number, _357eachCount_);
        }

        static int Add753(int[] numbers753, ref int index, int digits, int number, int[] _357eachCount)
        {
            for (int i = 0; i < 3; ++i)
            {
                AddNumber(numbers753, ref index, digits, number, i, _357eachCount);
            }

            return number;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int numberCount = 0;
            int numberCount_ = 1;
            for (int j = 1; j <= Digits; ++j)
            {
                numberCount_ *= 3;
                numberCount += numberCount_;
            }

            int[] numbers753 = new int[numberCount];

            int index = 0;
            int digits = -1;
            int[] _357eachCount = new int[3];

            Add753(numbers753, ref index, digits, 0, _357eachCount);

            int i = 0;
            int number = 0;
            int count = 0;
            while((number = numbers753[i]) != 0)
            {
                if (n >= number)
                {
                    ++count;
                }

                ++i;
            }

            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 13272
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt(),d = sc.nextInt();
		System.out.println(Math.max(a*b, c*d));
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;
 
    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));
 
    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));
 
    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));
 
    memo[N] = res;
 
    return res;
}
 
int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}

Measured memory_bytes: 4300
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	int K, S;
	cin >> K >> S;

	int t = K-S;
	if (t >= 0)
		cout << t << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	float a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	float s=0;
	for(int i=0;i<n;i++)
	s+=(1/a[i]);
	cout<<setprecision(9)<<1/s<<endl;
	return 0;
}

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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 1e6 + 7;
const ll mod = 1e9 + 7;

int n,k;
ll f[N];
int a[N];
int p[N];
int l[N];
int r[N];
ll sum_mx;
ll sum_mn;

int get( int x )
{
    return (p[x] == x ? x : p[x] = get(p[x]));
}

ll pw( ll x , ll y )
{
    if( y == 0 )return 1;
    if( (y & 1) ){
        return x * pw(x , y - 1) % mod;
    }else{
        ll b = pw(x , y / 2) % mod;
        return b * b % mod;
    }
}

void foo1()
{
    vector < pair < int , int > > v;
    for( int i = 1; i <= n; i++ ){
        v.push_back({a[i] , i});
    }
    sort( v.begin() , v.end() );
    for( int i = 0; i < n; i++ ){
        if( i < k - 1 )continue;
        ll y = f[i] * pw( f[k - 1] * f[i - k + 1] % mod , mod - 2 ) % mod;
        sum_mx = (sum_mx + y * v[i].fi) % mod;
    }
}

void foo2()
{
    vector < pair < int , int > > v;
    for( int i = 1; i <= n; i++ ){
        v.push_back({a[i] , i});
    }
    sort( v.rbegin() , v.rend() );
    for( int i = 0; i < n; i++ ){
        if( i < k - 1 )continue;
        ll y = f[i] * pw( f[k - 1] * f[i - k + 1] % mod , mod - 2 ) % mod;
        sum_mn = (sum_mn + y * v[i].fi) % mod;
    }
}

void solve1()
{
    cin >> n >> k;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
    }
    f[0] = 1;
    for( int i = 1; i < N; i++ ){
        f[i] = f[i - 1] * i % mod;
    }
    foo1();
    foo2();
    cout << ( sum_mx - sum_mn ) % mod;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  rep(i,n) cin >> a[i];

  //sort(a.begin(),a.end());
  vector<int> l(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);

  reverse(a.begin(),a.end());
  vector<int> r(n);
  rep(i,n-1) r[i+1] = gcd(r[i], a[i]);
  reverse(r.begin(), r.end());

  int ans = 0;
  rep(i,n) ans = max(ans,gcd(l[i], r[i]));

  cout << ans << endl;

}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;


const int MAX_SIZE = 100;

int d[MAX_SIZE];
int ans = 0;

void bubble_sort(int n){
	bool f = true;
	while(f){
		f = false;
		for(int j = n -1; j > 0; j--){
			if(d[j] < d[j - 1]){
				swap(d[j], d[j - 1]);
				f = true;
				ans++;
			}
		}
	}
}


int main(){
	int n;
	cin>>n;
	for(int i = 0; i < n; i++) cin>>d[i];
	bubble_sort(n);
	for(int i = 0; i < n; i++){
		if(i != 0) cout<<" ";
		cout<<d[i];
	}
	cout<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 1160
N,D=map(int,input().split())
ans=0
keep=[]
lis=[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129]
for i in range(N):
  s=list(map(int,input().split()))
  keep.append(s)
for j in range(0,N):
  for k in range(j+1,N):
    num=0
    for l in range(D):
      num+=abs(keep[j][l]-keep[k][l])**2
    if num in lis:
      ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

ll even(int n){
  vector<int> nums(n/2,0);
  rep(i,n){
    int d = in();
    if(d&1);else return 0;
    d = d / 2;
    if(d<0 or nums.size() <= d)return 0;
    ++nums[d];
  }
  rep(i,n/2){
    if(nums[i]!=2)return 0;
  }
  return modpow(2,n/2);
}

ll odd(int n){
  vector<int> nums(n/2,0);
  bool zero = false;
  rep(i,n){
    int d = in();
    if(d==0){
      if(zero)return 0;
      zero = true;
      continue;
    }
    if(d&1)return 0;
    d = d / 2 - 1;
    if(d<0 or nums.size()<=d)return 0;
    ++nums[d];
  }
  rep(i,n/2){
    if(nums[i]!=2)return 0;
  }
  return modpow(2,n/2);
}

int main(){
  int n = in();
  if(n&1){
    cout << odd(n) << endl;
  }else{
    cout << even(n) << endl;
  }
  return 0;
}


Measured memory_bytes: 384
# 17-Character-Counting_Characters.py

# ?????????????????????
# ?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°????????????????????????????????? 
# ??????????°?????????¨??§??????????????\???????????????

# Input
# ?????°????????????????????????????????±???????????????????????????
# Output
# ?????????????????±???????????????????????¢???????????????????????°?????\??????????????¢?????§????????????????????????

# a : a????????°
# b : b????????°
# c : c????????°
#   .
#   .
# z : z????????°
# Constraints
# ??±???????????????????????° < 1200
# Sample Input
# This is a pen.
# Sample Output
# a : 1
# b : 0
# c : 0
# d : 0
# e : 1
# f : 0
# g : 0
# h : 1
# i : 2
# j : 0
# k : 0
# l : 0
# m : 0
# n : 1
# o : 0
# p : 1
# q : 0
# r : 0
# s : 2
# t : 1
# u : 0
# v : 0
# w : 0
# x : 0
# y : 0
# z : 0

import sys
 
s = str()
alphabet = "abcdefghijklmnopqrstuvwxyz"
 
for line in sys.stdin:
    s += line.lower()
    # print(list(s))

 
for c in alphabet:
    print("{} : {}".format(c, s.count(c)) )

Measured memory_bytes: 7392
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    D = Counter(A)

    for k, v in D.items():
        if v == 2:
            db = k
            break

    flg = 1
    right, left = 0, 0
    for i in range(n + 1):
        if flg and A[i] == db:
            left = i
            flg ^= 1
        elif A[i] == db:
            right = i
            break

    length = n - (right - left)

    # 二項係数(mod p)をO(1)で求める
    def cmb(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n - r] % mod

    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    for i in range(2, n + 2):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)

    def cmb_mod(n, r, mod):
        x, y = 1, 1
        for i in range(r):
            x = (x * (n - i)) % mod
            y = (y * (i + 1)) % mod
        return (x * pow(y, mod - 2, mod)) % mod

    for i in range(1, n + 2):
        res = cmb(n + 1, i, mod) - cmb(length, i - 1, mod)
        print(res % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 28692
#include <bits/stdc++.h>
using namespace std;
long long ans(long long n){
  long long answer=pow(2,n)-1;
  return answer;
}
int main() {
  long long H;
  cin>>H;
  long long n=0;
  while(H>0){
    n++;
    H/=2;
  }
  cout<<ans(n)<<endl;
}


Measured memory_bytes: 256
import math

a,b,c_deg = map(float,input().split())

sin_c = math.sin(c_deg*math.pi/180)
cos_c = math.cos(c_deg*math.pi/180)

s = a*b*sin_c/2.0
c = math.sqrt(a**2+b**2-2*a*b*cos_c)

print(s)
print(a+b+c)
print(s/a*2.0)

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

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(long long T, std::vector<long long> N, std::vector<long long> M,
           std::vector<long long> A, std::vector<long long> B) {
    for(int i = 0 ; i < T ; i++){
        cout << floor_sum(N[i], M[i], A[i], B[i]) << endl;
    }
}

int main() {
  long long T;
  scanf("%lld", &T);
  std::vector<long long> N(T - 1 - 0 + 1);
  std::vector<long long> M(T - 1 - 0 + 1);
  std::vector<long long> A(T - 1 - 0 + 1);
  std::vector<long long> B(T - 1 - 0 + 1);
  for (int i = 0; i < T - 1 - 0 + 1; i++) {
    scanf("%lld", &N[i]);
    scanf("%lld", &M[i]);
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(T, std::move(N), std::move(M), std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 5396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, l;
  cin >> n >> l;
  int sum = n * l + n * (n - 1) / 2;
  pii mi = pii(abs(l), l);
  rep(i, n) {
    if (chmin(mi.F, abs(l + i))) {
      mi.S = l + i;
    }
  }
  cout << sum - mi.S << endl;
}


Measured memory_bytes: 256
using System;

namespace _120_ABC
{
    class Program01
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');
            int A = int.Parse(Input[0]);
            int B = int.Parse(Input[1]);
            int C = int.Parse(Input[2]);

            int Answer = Math.Min(B / A, C);

            Console.WriteLine(Answer);

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
int m, n;
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
char map[125][125];
char f;
int ans;
using namespace std;
void dfs(int x,int y)
{
    for (int i = 0; i < 4; ++i)
    {
        int nx = x + dir[i][0],ny = y + dir[i][1];
        if (nx >= 1 && nx <= m && ny >= 1 && ny <= n && map[nx][ny] == f)
        {
            map[nx][ny] = ' ';
            dfs(nx,ny);
        }
    }
}

int main()
{
    while (cin >> m >> n && (m || n))
    {
        ans = 0;//豐。譛牙?蟋句喧謌台ケ滓弍驢我コ??縲ゅ?
        for (int i = 1; i <= m; ++i)
            for (int j = 1; j <= n; ++j)
                cin >> map[i][j];
        for (int i = 1; i <= m; ++i)
            for (int j = 1; j <= n; ++j)
            {
                if (map[i][j] != ' ')
                {
                    ans++;
                    f = map[i][j];
                    dfs(i,j);
                }
            }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1484
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T;
  cin>>S>>T;
  int ans = 0;
  for(int i=0;i<S.size();++i){
    if(S[i]!=T[i]) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3832
import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  h <- getIntVec n

  dp <- VM.new n
  VM.write dp 0 0
  VM.write dp 1 (abs (h V.! 0 - h V.! 1))
  forM_ [2..n-1] $ \i -> do
    c2 <- VM.read dp (i - 2)
    c1 <- VM.read dp (i - 1)
    let c2' = c2 + abs (h V.! i - h V.! (i - 2))
        c1' = c1 + abs (h V.! i - h V.! (i - 1))
    VM.write dp i (min c1' c2')

  ans <- VM.read dp (n-1)
  print ans

Measured memory_bytes: 3580
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1010000

enum Type{
	prime,
	mult,
};

bool is_prime[NUM];
ll table[100001];
ll dp[100001][2];

int main(){

	for(int i = 0; i < NUM; i++)is_prime[i] = true;

	is_prime[0] = false;
	is_prime[1] = false;

	for(int i = 2; i <= sqrt(NUM); i++){
		if(is_prime[i]){
			for(int k = 2*i; k < NUM; k += i){
				is_prime[k] = false;
			}
		}
	}

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++)scanf("%lld",&table[i]);

	if(!is_prime[table[0]]){
		printf("0\n");
		return 0;
	}

	for(int i = 0; i < N; i++){
		dp[i][prime] = 0;
		dp[i][mult] = 0;
	}

	dp[0][prime] = 1;

	for(int i = 1; i <= N-1; i++){
		dp[i][mult] += dp[i-1][prime];

		if(is_prime[table[i]]){

			if(table[i-1] < table[i] && is_prime[table[i-1]] == true){
				dp[i][prime] += dp[i-1][prime];
			}

			if(i >= 2 && table[i-2] < table[i] && is_prime[table[i-2]] == true){
				dp[i][prime] += dp[i-1][mult];
			}
		}
		dp[i][mult] %= MOD;
		dp[i][prime] %= MOD;
	}

	ll ans = dp[N-1][prime]+dp[N-1][mult];
	ans %= MOD;

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 6464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
int dy[4] = {-1, 0, 1, 0}, dx[4] = {0, -1, 0, 1};

int main(void)
{
	int r, c;
	cin >> r >> c;
	int ans = r * c;
	string maze[r];
	int dist[r][c];
	rep (i, r) rep (j, c) dist[i][j] = INT16_MAX;
	rep (i, r) cin >> maze[i];
	rep (i, r) rep (j, c) if (maze[i][j] == '#') ans--;
	
	dist[0][0] = 0;
	queue<std::pair<P, int> > q;
	q.push(make_pair(make_pair(0, 0), 1));
	while (q.size() != 0) {
		auto p = q.front();
		P now = p.first;
		// cout << "(" << now.second << "," << now.first << ") -> ";
		int dist_now = p.second;
		q.pop();
		rep (d, 4) {
			int y = dy[d] + now.first, x = dx[d] + now.second;
			if (0 <= y && y < r && 0 <= x && x < c) {
				if (INT16_MAX == dist[y][x] && maze[y][x] != '#') {
					dist[y][x] = dist_now + 1;
					q.push(make_pair(make_pair(y, x), dist_now + 1));
					// cout << "(" << x << "," << y << ") ";
				}
			}
		}
		// cout << endl;
	}
	if (dist[r - 1][c - 1] < INT16_MAX) {
		cout << ans - dist[r - 1][c - 1] << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
int i,c;
for (i = 0; i < values.length; i++) {
values[i] = i + 1;
}
for (i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0]) - 1;
int b = Integer.parseInt(ab[1]) - 1;
c= values[a];
values[a]=values[b];
values[b]=c;
}
for(i=0;i<values.length;i++){
System.out.printf("%d\n",values[i]);}

}
}
}



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

using namespace std;

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

    s = "0"+s;
    vector <vector <int> > des(s.size(), vector <int> (30, -1));
    vector <int> despues(30, -1);

    for(int i=s.size()-1; i>=0; i--)
    {
        des[i] = despues;
        despues[s[i]-'a'] = i;
    }

    long long vueltas = 0;
    int i = 0;
    bool restar = false;
    for(int j=0; j<t.size(); j++)
    {
        i = des[i][t[j]-'a'];
        if(i == -1)
        {
            if(des[0][t[j]-'a'] == -1)
            {
                cout << -1 << endl;
                return 0;
            }
            vueltas++;
            i = des[0][t[j]-'a'];
        }
        restar = false;
    }

    long long res = vueltas*((long long)s.size()-1) + i - restar;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 15232
Node = Struct.new(:key, :left, :right)

class Tree
  def initialize
    @root = nil
  end
  
  def insert(key)
    unless @root
      @root = Node.new(key)
      return
    end
    node = @root
    while node
      if key < node.key
        if node.left
          node = node.left
        else
          node.left = Node.new(key)
          break
        end
      else
        if node.right
          node = node.right
        else
          node.right = Node.new(key)
          break
        end
      end
    end
  end
  
  def preorder
    traverse = ->(node) {
      if node
        yield(node.key)
        traverse.(node.left)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
  
  def inorder
    traverse = ->(node) {
      if node
        traverse.(node.left)
        yield(node.key)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
end

t = Tree.new

$<.gets.to_i.times do
  com, key = $<.gets.split
  case com
  when "insert" then t.insert(key.to_i)
  when "print"
    t.inorder  {|key| print " #{key}"}
    puts
    t.preorder {|key| print " #{key}"}
    puts
  end
end


Measured memory_bytes: 31544
#include <array>
#include <cstddef>
#include <iostream>
#include <vector>

const int N = 8;
const int FREE = 1;
const int NOT_FREE = 0;
struct Position
{
    int r, c;
};

std::array<int, N> row;
std::array<int, N> col;
std::array<int, 2 * N - 1> dpos;
std::array<int, 2 * N - 1> dneg;
std::array<bool, N> fixed_row;
std::array<int, N> col4row;

bool canPut(int i, int j)
{
    return row[i] && col[j] && dpos[i + j] && dneg[i - j + N - 1];
}

void put(int r, int c)
{
    row[r] = NOT_FREE;
    col[c] = NOT_FREE;
    dpos[r + c] = NOT_FREE;
    dneg[r - c + N - 1] = NOT_FREE;
    col4row[r] = c;
}

void remove(int r, int c)
{
    row[r] = FREE;
    col[c] = FREE;
    dpos[r + c] = FREE;
    dneg[r - c + N - 1] = FREE;
}

void dfs(int r, int c)
{
    if (r == N)
    {
        return;
    }
    if (c == N)
    {
        auto prev_row = r - 1;
        while (fixed_row[prev_row])
        {
            prev_row--;
        }
        auto prev_col = col4row[prev_row];
        remove(prev_row, prev_col);
        dfs(prev_row, prev_col + 1);
        return;
    }
    if (fixed_row[r])
    {
        dfs(r + 1, 0);
        return;
    }
    if (canPut(r, c))
    {
        put(r, c);
        dfs(r + 1, 0);
    }
    else
    {
        dfs(r, c + 1);
    }
}

int main()
{
    int k;

    row.fill(FREE);
    col.fill(FREE);
    dneg.fill(FREE);
    dpos.fill(FREE);
    fixed_row.fill(false);

    std::cin >> k;
    int r, c;
    for (size_t i = 0; i < k; ++i)
    {
        std::cin >> r >> c;
        fixed_row[r] = true;
        put(r, c);
    }

    dfs(0, 0);

    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if (j == col4row[i])
            {
                std::cout << "Q";
            }
            else
            {
                std::cout << ".";
            }
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 3136
#include<stdio.h>

#define MAX 2000

int n,arr[MAX];

int solve(int,int);

int main(){

  int i,M,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)){
      printf("yes\n");
    }
    else printf("no\n");
  }
  
  return 0;
}

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

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >>c>>d;

  while (true) {
    c=c-b;
    if(c<=0){
      cout <<"Yes" <<endl;
      break;
    }
    a=a-d;
        if(a<=0){
      cout <<"No" <<endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>

int main(){
    int count[4] = {0, 0, 0, 0};
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::string S;
        std::cin >> S;
        if(S == "AC") count[0]++;
        else if(S == "WA") count[1]++;
        else if(S == "TLE") count[2]++;
        else if(S == "RE") count[3]++;
    }

    std::cout << "AC x " << count[0] << std::endl;
    std::cout << "WA x " << count[1] << std::endl;
    std::cout << "TLE x " << count[2] << std::endl;
    std::cout << "RE x " << count[3] << std::endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<max(0ll,(n-1)*b+a-(n-1)*a-b+1)<<endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    string t="WB";
    cin >> s;
    int n=s.size();
    int c=0,ans=0;
    if(s[0]=='B') c=1;
    rep(i,n){
        if(s[i]==t[c]) continue;
        else{
            if(t[c]=='W') c=1;
            else c=0;
            ++ans;
        }
    }
    
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
using namespace atcoder;
typedef long long LL;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

int main(){
    iostream_init();

    int N, Q;
    cin >> N >> Q;
    dsu d(N);
    REP(i, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        } else {
            cout << (d.same(u, v) ? 1 : 0) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3968
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 100000;
const ll MAX_COST = 10000000000;
const ll INF = MAX_N * MAX_COST;

struct Edge {
  int l;
  int r;
  int c;

  Edge(int l = -1, int r = -1, int c = -1) {
    this->l = l;
    this->r = r;
    this->c = c;
  }

  bool operator>(const Edge &e) const {
    return l * MAX_COST + c > e.l * MAX_COST + e.c;
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  priority_queue <Edge, vector<Edge>, greater<Edge>> pque;
  int l, r, c;
  for (int i = 0; i < M; ++i) {
    cin >> l >> r >> c;
    pque.push(Edge(l, r, c));
  }

  ll dist[N + 10];

  for (int i = 0; i <= N; ++i) {
    dist[i] = INF;
  }

  dist[1] = 0;

  while (!pque.empty()) {
    Edge edge = pque.top();
    pque.pop();

    ll cost = dist[edge.l] + edge.c;

    if (dist[edge.r] > cost) {
      for (int j = edge.l; j <= edge.r; ++j) {
        dist[j] = min(dist[j], cost);
      }
    }

    // fprintf(stderr, "(%d, %d, %d)\n", edge.l, edge.r, edge.c);
  }

  if (dist[N] == INF) {
    cout << -1 << endl;
  } else {
    cout << dist[N] << endl;
  }

  return 0;
}


Measured memory_bytes: 2292
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const int N=2055;
const ll mod=1e9+7;
ll finv[200050],fac[200500];
ll dp[5000][5000];
ll a[200050],b[200500];
ll ksm(ll n,ll k)
{
	ll ret=1;
	while(k)
	{
		if(k%2) ret=ret*n%mod;
		k/=2; n=n*n%mod;
	}
	return ret;
}
ll invd()
{
	fac[1]=1;
	for(int i=2;i<=200000;++i) fac[i]=i*fac[i-1]%mod;
	finv[200000]=ksm(fac[200000],mod-2);
	for(int i=200000;i>1;--i) finv[i-1]=finv[i]*i%mod;
}
ll C(ll n,ll m)
{
	return fac[n]*finv[m]%mod*finv[n-m]%mod;
}
int main (){
	int n;
	scanf("%d",&n);
	invd();
	for(int i=1;i<=n;++i)scanf("%lld%lld",a+i,b+i);
	for(int i=1;i<=n;++i)dp[N-a[i]][N-b[i]]++;
	for(int i=1;i<=2*N;++i) for(int j=1;j<=2*N;++j) dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
	ll ans=0;
    for(int i=1;i<=n;++i) ans=(ans+dp[a[i]+N][b[i]+N])%mod;
    for(int i=1;i<=n;++i) ans=(ans-C(a[i]*2+b[i]*2,2*a[i])+mod)%mod;
    printf("%lld\n",finv[2]%mod*ans%mod); 
}

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

vector<int> primes={2,3,5,7,11,
                    13,17,19,23,29,
                    31,37,41,43,47,
                    53,59,61,67,71,
                    73,79,83,89,91,
                    97};

int main(){
  int n;
  cin>>n;
  vector<int> sisu(26);
  rep(i,26){
    int p=0;
    int q=primes[i];
    while(q<=n){
      p+=n/q;
      q*=primes[i];
    }
    sisu[i]=p;
  }
  int ans=0;
  if(sisu[0]>=74) ans++;
  int ijo2=0,ijo4=0,ijo14=0,ijo24=0;
  rep(i,26){
    if(sisu[i]>=2) ijo2++;
    if(sisu[i]>=4) ijo4++;
    if(sisu[i]>=14) ijo14++;
    if(sisu[i]>=24) ijo24++;
  }
  ans+=(ijo2-1)*ijo24+(ijo4-1)*ijo14+(ijo2-2)*ijo4*(ijo4-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 3588