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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I1000000007 (1000000007)
#define I998244353   (998244353)
#define IINF             (1<<28)
#define LINF           (1LL<<60)
#define ALL(a)         (a).begin(), (a).end()
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}
template<std::int_fast64_t divisor> struct modint {
  using i64 = std::int_fast64_t;

  i64 val;

  constexpr modint(i64 v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }

  constexpr modint operator + (const modint& rhs) const noexcept {
    return modint(*this) += rhs;
  }

  constexpr modint operator - (const modint& rhs) const noexcept {
    return modint(*this) -= rhs;
  }

  constexpr modint operator * (const modint& rhs) const noexcept {
    return modint(*this) *= rhs;
  }

  constexpr modint operator / (const modint& rhs) const noexcept {
    return modint(*this) /= rhs;
  }

  constexpr modint operator ~ () const noexcept {
    i64 a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      i64 t = a / b;
      a -= t * b;
      u -= t * v;
      i64 c = a; a = b; b = c;
      i64 w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }

  constexpr modint& operator += (const modint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }

  constexpr modint& operator -= (const modint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }

  constexpr modint& operator *= (const modint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }

  constexpr modint& operator /= (const modint& rhs) noexcept {
    val = val * (~(modint(rhs))).val % divisor;
    return *this;
  }

  friend modint modpow (modint a, i64 n) noexcept {
    auto res = modint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }

  friend std::ostream& operator << (std::ostream& os, const modint& a) noexcept {
    return os << a.val;
  }
};

namespace solver {
  using namespace std;
  using ll = long long;
  using mint = modint<I1000000007>;

  int N, A, B;

  void init() {
    cin >> N >> A >> B;
  }

  void solve() {
    mint ans = modpow(mint(2), N);
    mint a = 1;
    REPC(i, 1, B) {
      a = a * (N-i+1) / i;
      if(i == A || i == B) ans -= a;
    }
    ans -= 1;
    cout << ans << endl;
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
	};
	sort(ALL(A));
	reverse(ALL(A));

	vector<ll> hen;
	REP(i, N - 1) {
		if (A[i] == A[i + 1]) {
			hen.emplace_back(A[i]);
			i++;
		}
	}

	sort(ALL(hen));
	reverse(ALL(hen));
	if (hen.size() < 2) {
		cout << 0 << endl;
	} else {
		cout << hen[0] * hen[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
char s[1111];
string ss;
int main(void){
  fgets(s,sizeof(s),stdin);
  ss = (string)s;
  int p = 0;
  int c = 0;
  string sss;
  string res;
  for(int i = 0; i < (int)ss.size(); i++,c++){
    if(ss[i] == ',' || ss[i] == '.' || ss[i] == ' '){
      sss = ss.substr(p,c);
      if(3 <= (int)sss.size() && (int)sss.size() <= 6){
	if((int)res.size()) res += ' ';
	res += sss;
      }
      p = i + 1;
      c = -1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1180
import sys
import math
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(x):
  l = []
  for i in range(N):
    l.append(a[i]%x)
  l.sort()

  aa = 0
  bb = 0
  for i in l:
    tmp = i
    if aa + tmp > K:
      bb += x-tmp
      if bb > K:
        return False
    else:
      aa += tmp
  else:
    return True

N,K = IL()
a = IL()
num = sum(a)
ans = []

for i in range(1,int(math.sqrt(num)+1)):
  if num%i == 0:
    if judge(i):
      ans.append(i)
    if judge(num//i):
      ans.append(num//i)

print(max(ans))

Measured memory_bytes: 40924
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//ソートすればいいんですか？
//???

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


	int N, T;
	scanf("%d", &N);
	scanf("%d", &T);
	int AB[3000];
	rep(i, N) {
		int a, b;
		scanf("%d %d", &a, &b);
		AB[i] = (a << 12) + b;
	}
	sort(AB, AB + N);

	vector<int> dp(3000);
	int saidai = 0;
	rep(i, N) {
		int a = AB[i] >> 12;
		auto dp2 = dp.begin() + a;
		int b = AB[i] & ((1 << 12) - 1);
		chmax(saidai, dp[0] + b);
		rep(j, T - a) {
			chmax(dp[j], dp2[j] + b);
		}
	}
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double ans,d,x,S; int n;
int main()
{
	cin>>n>>d>>x;
	S=2*n*d+1.0*(2*n-1)*n*x;
	for(int i=n;i>=1;i--) ans+=S/2/i,S-=S/i/i;
	printf("%.10Lf",ans);
	return 0;
}


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

int main() {
	long long INF = 1000000000000;
	int N, M, X;
	cin >> N >> M >> X;
	vector<long long> C(N);
	vector<vector<long long> > A(N, vector<long long>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	long long ANS = INF;
	for (int i = 0; i < (1 << N); i++) {
		vector<long long> COUNT(M, 0);
		long long COST = 0;
		long long I = i;
		for (int j = 0; j < N; j++) {
			if (I % 2 == 1) {
				COST += C[j];
				for (int k = 0; k < M; k++) {
					COUNT[k] += A[j][k];
				}
			}
			I /= 2;
		}
		bool check = true;
		for (int j = 0; j < M; j++) {
			if (COUNT[j] < X) check = false;
		}
		if (check) {
			ANS = min(ANS, COST);
		}
	}
	cout << (ANS == INF ? -1 : ANS) << endl;
}

Measured memory_bytes: 3636
N=int(input())
c=[0]*(N-1)
s=[0]*(N-1)
f=[0]*(N-1)
for i in range(N-1):
    c[i],s[i],f[i]=map(int,input().split())
time=0
ans0=[0]
for j in range(N-1):
    time=0
    for i in range(j,N-1):
        if time<=s[i]:
            time=s[i]+c[i]
            ans0.append(time)
        else:
            q=time//f[i]
            if time%f[i]==0:
                q-=1
            time=(q+1)*f[i]+c[i]
    print(time)
print(0)
    
    

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

int main() {
	string S;
	cin >> S;
	int num = 0;

	int len = S.length();
	if (len % 2 == 0) {
		for (int i = 0; i < (S.length() / 2); i++) {
			if (S[i] != S[len - i - 1]) {
				num += 1;
			};
		};
	}
	else {
		for (int i = 0; i < (S.length()-1) / 2; i++) {
			if (S[i] != S[len - i - 1]) {
				num += 1;
			};
		};
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int n;
void solve() {  
    cin >> n;
    string ans = "";
    while (n) {
        int r = n % 26;
        if (!r)
            ans += 'z';
        else
            ans += char('a' + r - 1);
        --n;
        n /= 26;
    }    
    reverse(all(ans));
    cout << ans;
}       

Measured memory_bytes: 3672
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <string>
#include <iostream>
#include <functional>
using namespace std;
typedef long long ll;

int main()
{
	int H, A;
	scanf("%d %d", &H, &A);

	int t = 0;
	while (H > 0) H -= A, t++;
	printf("%d", t);
	return 0;
}

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

int main(){
    int ans=0;
    int n,timeq;
    string name;
    int time=0,ptime;

    cin >> n >> timeq;
    
    pair <string,int> p;
    queue <pair< string , int> > q;

    for (int i = 0; i < n; i++){
        cin >> name >> ptime;
        q.push(make_pair(name,ptime));
    }
    
    while (q.size() > 0){
        p=q.front();
        q.pop();
        time += min(timeq,p.second);
        p.second -= min(timeq,p.second);
        
        if(p.second == 0){
            cout << p.first << " " << time << endl;
        }else{
            q.push(p);
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}



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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private int N;
  private int K;
  private String[] D;

  private void solve(Scanner sc, PrintWriter out) {
    N = sc.nextInt();
    K = sc.nextInt();
    D = new String[K];
    for (int i = 0; i < K; ++i) {
      D[i] = sc.next();
    }

    boolean found = true;
    int n = N;
    while (found) {
      found = false;

      StringBuilder sb = new StringBuilder();
      sb.append(n);
      for (int i = 0; i < K; ++i) {
        if (sb.indexOf(D[i]) >= 0) {
          found = true;
          break;
        }
      }
      if (!found) {
        break;
      }
      ++n;
    }
    out.println(n);
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 15952
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;

int n;
string s[55];
int dat[55][30];
int ans[30];

int main() {

	cin>>n;
	FORI(0,n){
		cin>>s[i];
	}
	FORI(0,n){
		FORJ(0,s[i].size()){
			dat[i][s[i][j]-'a']++;
		}
	}

	FORJ(0,26){
		ans[j]=dat[0][j];
	}
	FORI(1,n){
		FORJ(0,26){
			ans[j]=min(ans[j], dat[i][j]);
		}
		
	}

	FORI(0,26){
		FORJ(0,ans[i]){
			printf("%c", i+'a');
		}
	}
	printf("\n");
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <climits>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

int main()
{
	int n, k;
	cin >> n;
	cin >> k;
	int a=1;
	rep(i, n){
		if(a*2 > a+k){
			a = a+k;
		}else{
			a = 2 * a;
		}
	}

	cout << a << endl;
}



Measured memory_bytes: 256
using System.Text;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var a = new long[11];
        var b = new long[11];
        a[0] = 9 * 1; b[0] = a[0];
        for (int i = 1; i < 11; i++)
        {
            a[i] = (i + 1) * 9 * (long)Pow(10, i);
            b[i] = a[i] + b[i - 1];
        }
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            if (n == 0 && k == 0) break;
            var t1 = 0;
            for (int i = 0; i < 11; i++)
                if (b[i] >= n) { t1 = i; break; }
            var t2 = t1 == 0 ? n - 1 : n - b[t1 - 1] - 1;
            var t3 = t2 / (t1 + 1);
            var t4 = t2 % (t1 + 1);
            var t5 = (int)Pow(10, t1) + t3;
            var t6 = t5.ToString().Substring((int)t4);
            putAns(k, (int)t5, t6);
        }
    }
    static void putAns(int k, int t5, string t6)
    {
        var sb = new StringBuilder();
        sb.Append(t6);
        var p = t5 + 1;
        while (sb.Length < k)
        {
            sb.Append((p++).ToString());
        }
        Console.WriteLine(sb.ToString().Substring(0, k));
    }
}



Measured memory_bytes: 13824
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int a2 = a * a;
		int a3 = a2 * a;
		System.out.println(a + a2 + a3);
	}
	
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int X,Y;
bitset<40000> B;
int hoge(vector<int> V,int X) {
	B.reset();
	B[X+20000]=1;
	FORR(v,V) {
		B=(B>>v)|(B<<v);
	}
	return B[20000];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>X>>Y;
	reverse(ALL(S));
	while(S.size()&&S.back()=='F') {
		X--;
		S.pop_back();
	}
	
	
	vector<int> V[2];
	x=0;
	while(S.size()) {
		if(S.back()=='T') {
			x^=1;
			V[x].push_back(0);
		}
		else {
			V[x].back()++;
		}
		S.pop_back();
	}
	
	if(hoge(V[0],X) && hoge(V[1],Y)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC160C
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = RInt;
            var N = RInt;
            var A = RInts.ToList();
            var B = A.Select(x => x + K).ToArray();
            A.AddRange(B);

            Draw1D(A.ToArray());

            int ans = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                if (A[i + N - 1] - A[i] < ans) ans = A[i + N - 1] - A[i];
            }
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main()
{
	int n,s=0,p,i;
    cin>>n;
    p=n;
	do{
		s=s+p%10;
		p=p/10;
	} while(p!=0);
	
	if(n%s==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

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

    if (N == 1 && M == 1)
    {
        cout << 1 << endl;
    }
    else if (N == 1 || M == 1)
    {
        cout << max(N, M) - 2 << endl;
    }
    else
    {
        long long ans = (long long)(N - 2) * (M - 2);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
s = list(input())
l, r = 0, len(s) - 1
ans = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    else:
        if s[l] == "x":
            l += 1
            ans += 1
        elif s[r] == "x":
            r -= 1
            ans += 1
        else:
            ans = -1
            break

print(ans)


Measured memory_bytes: 9800
import sys
n,d = map(int, sys.stdin.readline().rstrip("\n").split())
x = [ [int(s) for s in line.split()] for line in sys.stdin ]
ans = 0
l = [False]*20001
for m in range(1,142):
    l[m*m] = True
for i in range(n):
    for j in range(i+1,n):
        distance = 0
        for dim in range(d):
            distance += (x[i][dim] - x[j][dim])**2
        if l[distance]:
            ans += 1
print(ans)

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

int main(){
  int N;
  cin >>N;
  vector<int> height(N);
  for(int i=0;i<N;i++){
    int x;
    cin >>x;
    height[i] = x;
  }
  
  vector<int> dp(N,0);
  dp[1] = abs(height[1] - height[0]);
  
  for(int i=2;i<N;i++){
    int choice1 = dp[i-1] + abs(height[i] - height[i-1]);
    int choice2 = dp[i-2] + abs(height[i] - height[i-2]);
    dp[i] = min(choice1,choice2);
  }
  
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
    double N,M,sum=0;
    int a=0;
    cin >> N >> M;

    vector<double> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum+=A.at(i);
    }
    for (int i = 0; i < N; i++) {
        if(A[i]>=sum/(4*M)) a++;
    }
    
    if(a>=M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	long long Big = 1000000001;
	mcf_graph<int, long long> graph(N * (N + 2) + 2);
	for (int i = 0; i < N; i++) graph.add_edge(0, N * N + i + 1, K, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int A;
			cin >> A;
			graph.add_edge(N * N + i + 1, i * N + j + 1, 1, Big - A);
			graph.add_edge(i * N + j + 1, N * N + N + j + 1, 1, 0);
		}
	}
	for (int j = 0; j < N; j++) graph.add_edge(N * N + N + j + 1, N * (N + 2) + 1, K, 0);
	graph.add_edge(0, N * (N + 2) + 1, N * K, Big);

	auto p = graph.flow(0, N * (N + 2) + 1, N * K);
	cout << Big * p.first - p.second << endl;

	int edge_id = N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (graph.get_edge(edge_id).flow == 1) cout << "X";
			else cout << ".";
			edge_id += 2;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4248
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int DN=3005,M=1e9+7;
long long n,a[DN],dp[2][DN][DN];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    for(int l=1;l<=n;l++)
    {
    	for(int i=1;i<=n-l+1;i++)
    	{
    		int j=i+l-1;
    		if(i==j)
    		{
    			dp[0][i][j]=a[i];
    			dp[1][i][j]=-a[i];
    		}
    		dp[0][i][j]=max(a[i]+dp[1][i+1][j],a[j]+dp[1][i][j-1]);
    		
    		dp[1][i][j]=min(-a[i]+dp[0][i+1][j],-a[j]+dp[0][i][j-1]);
    	}
    }
    cout<<dp[0][1][n];
}

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

int main(){
  int A, B, X;
  cin >> A >> B >> X;
  if(A>X){
    cout << "NO" << endl;
    return 0;
  }
  if(B>=X-A){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <cinttypes>
#include <cstdio>
#include <vector>

using namespace std;

int64_t gcm(int64_t a, int64_t b) {
    int64_t result = a;
    int64_t k = 0;
    int64_t n = b;
    do {
        k = result % n;
        result = n;
        n = k;
    } while (k != 0);
    return result;
}

int64_t lcm(int64_t a, int64_t b) {
    int64_t g;
    g = gcm(a, b);
    return a * (b / g);
}

int64_t lcm_n(const vector<int64_t> &numbers) {
    int64_t l;
    l = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        l = lcm(l, numbers[i]);
    }
    return l;
}

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int64_t T;
    vector<int64_t> vt;
    for (int i = 0; i < N; i++)
    {
        if (scanf("%" PRId64, &T) < 1) return 0;
        vt.push_back(T);
    }

    printf("%" PRId64 "\n", lcm_n(vt));
    return 0;
}


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

using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( i = 0; i < (int)n; ++i )
typedef long long ll;

int main()
{
    //IOS

    int animals, legs;
    cin >> animals >> legs;

    int turtles, cranes;

    if ( ( legs % 4 == 0 && (legs / 4) == animals ) || ( legs % 2 == 0 && (legs / 2) == animals ) ) cout << "Yes\n";
    else
    {
        int turtles, cranes; bool dec = false;
        for( turtles = ( legs / 4 ); turtles > 0; --turtles )
        {
            cranes = legs - ( turtles * 4 );
            if ( (cranes & 1) == 0 && cranes > 0 ) cranes /= 2;
            else continue;

            if ( cranes + turtles == animals )
            {
                dec = true; break;
            }
        }

        cout << ( dec ? "Yes" : "No" ) << '\n';
    }

    return 0;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
c = 0
ic = 1
for i in range(n-1):
    if i == 0:
        ans += a[0]
    else:
        ans += a[ic]
        c += 1
        if c == 2:
            c = 0
            ic += 1
print(ans)


Measured memory_bytes: 31400
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
lp,ls=[],[]
for _ in range(m):
  p,s=input().split()
  lp.append(int(p)-1)
  ls.append(s=='AC')
la,lw=[0]*n,[0]*n
for p,s in zip(lp,ls):
  if la[p]<1:
    if s: la[p]=1
    else: lw[p]+=1
print(sum(la),sum(w*a for a,w in zip(la,lw)))

Measured memory_bytes: 9416
import numpy as np
import sys
X, N = np.array(list(map(int, input().split())))
if N == 0:
    print(X)
    sys.exit()
p = np.array(list(map(int, input().split())))
p = np.sort(p)
a = np.ones(304, dtype = np.int)
a[p+102] = 0
m = X+1000
n = 0
for i in range(304):
    if a[i] == 1:
        if m>abs(i-X-102):
            m = abs(i-X-102)
            n = i-102
print(int(n))

Measured memory_bytes: 27228
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int a = 0, b = 0, c = 0, d = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == '0')a++;
		if (i % 2 == 0 && s[i] == '1')b++;
		if (i % 2 == 1 && s[i] == '0')c++;
		if (i % 2 == 1 && s[i] == '1')d++;
	}

	int ans = min(b + c, a + d);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
using namespace std;

//long long A[100000];
//int stand_bit_num[40];

//int t[1000000];
//long long d[100000];

vector <int> edges[100000];
vector <int> reverse_edges[100000];
int parent[100000];
int used_reverse_edge_count[100000];

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

    for(int i = 0; i <N + M - 1; i++){
        int a;
        int b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        reverse_edges[b-1].push_back(a-1);
    }

    int source;
    for(int i = 0; i <N; i++){
        if(reverse_edges[i].size() == 0){
            source = i;
            break;
        }
    }
    for(int i = 0; i < N; i++){
        used_reverse_edge_count[i] = 0;
    }

    queue <pair <int, int> > q;
    q.push(make_pair(-1, source));

    while(!q.empty()){
        auto p = q.front();
        q.pop();
        int prev = p.first;
        int cur = p.second;
        if(used_reverse_edge_count[cur] < (int)reverse_edges[cur].size() - 1){
            used_reverse_edge_count[cur] ++;
            continue;
        }
        parent[cur] = prev;

        for(int i = 0; i < edges[cur].size(); i++){
            q.push(make_pair(cur, edges[cur][i]));
        }
    }

    for(int i = 0; i < N; i++){
        cout << parent[i] + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1, 0);
    rep(i, n - 1)
    {
        int k;
        cin >> k;
        a[k] += 1;
    }
    for (int i = 1; i < n + 1; i++)
        cout << a[i] << endl;
}


Measured memory_bytes: 4044
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 200000
#define N_MAX 100000
#define M_MAX 200000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

ull n, m;
int h, w;
int i, j, k;
int a, b;

char s[S_MAX + 1];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){
	ull result = 0;
	ull prev;

	n--;
	result = (n / 11) * 2 + ((n % 11 < 6) ? 1 : 2);

	printf("%llu\n", result);

	return;
}

int main (void) {
	char *t;
	scanf("%llu", &n);

	solve();
	return 0;
}




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

int main() {
    int n,k; cin >> n >> k;
    int d[110] = {};
    for (int i = 0; i < k; i++) {
        int dd; cin >> dd;
        for (int j = 0; j < dd; j++) {
            int x; cin >> x;
            d[x]++;
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (d[i] == 0) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3596
n,k=map(int,input().split())
s=input()
from itertools import groupby
a=[len(list(j)) for i,j in groupby(s)]
if s[0]=='0':
  a=[0]+a
if s[n-1]=='0':
  a=a+[0]
w=2*k+1
if len(a)<=w:
  print(n)
  exit()
m=sum(a[:w])
x=m
for i in range(2,len(a)-2*k,2):
  m=m-a[i-1]-a[i-2]+a[i+w-1]+a[i+w-2]
  x=max(x,m)
print(x)

Measured memory_bytes: 4980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int A, B;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.NextInt();
            B = sc.NextInt();
        }


        public void Solve()
        {
            Scan();
            int def = B - A;
            int AA = (def * (def - 1) / 2);
            Console.WriteLine(AA - A);
        }


        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;

	vector<int> bla(N + 1), whi(N + 1);
	for (int i = 0; i < N; i++) {
		whi[i + 1] = whi[i];
		bla[i + 1] = bla[i];
		if (S[i] == '#') {
			bla[i + 1]++;
		}
		else {
			whi[i + 1]++;
		}
	}

	int ans = (int)1e9;
	for (int i = 0; i < N+1; i++) {
		int tmp;
		tmp = (bla[i] - bla[0]) + (whi[N] - whi[i]);
		ans = min(ans, tmp);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2180
#include <cstdio>

int main() {
	int N;
	scanf("%d", &N)+1;

	int* A1 = new int[N];
	int* A2 = new int[N+1];

	int tmp, total = 0;

	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp)+1;
		total += tmp;
		A1[i] = total;
	}

	A2[0] = total;
	for (int i = 0; i < N; i++) {
		scanf("%d", &tmp)+1;
		total -= tmp;
		A2[i+1] = total;
	}

	for (int i = 0; i < N + 1; i++) {
		A2[i] -= total;
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		tmp = A1[i] + A2[i];
		if (tmp > ans) ans = tmp;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  int a;
  if(2*x==w&&2*y==h) a = 1;
  else a = 0;
  cout << ((double)(w)*(double(h)))/2.0 << " " << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a, b, c;
    cin >> a>> b>> c;

    if ((a==b && b==c) || (a!=b && b!=c && c!=a))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
 
  if (a == 0) {
    cout << 1 << endl;
  }
  else if (b== 0) {
    cout << 2 << endl;
  }
  else if (c== 0) {
    cout << 3 << endl;
  }
  else if (d== 0){
    cout << 4 << endl;
   } 
  else if ( e==0){
  cout << 5 <<endl;
  }
 }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    bool a[100010]={0};
    a[0]=a[1]=1;
    for(int i=2;i*i<=100000;i++) {
        if(a[i]==0)for(int j=i+i;j<100009;j+=i)a[j]=1;
    }
    int b[100000]={0};
    for(int i=1;i<100000;i+=2) b[i]=b[i-2]+!(a[i]||a[(i+1)/2]);

    int q,l,r,ans;
    cin>>q;
    rep(i,q){
        ans=0;
        cin>>l>>r;
        if(l==1)l=3;
        cout<<b[r]-b[l-2]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
    int n, cnt = 0;
    cin >> n;
    if (n % 2 == 0) --n;
    for (int i = 1; i <= n; i += 2) {
        int tmp = 0;
        int x = i;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) ++tmp;
        }
        if (tmp >= 8) ++cnt;
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){
    int x[10000];
    
    int n=0;
    while(true){
        if (n>10000) return -1;
        
        cin >> x[n];
        
        if(x[n] == 0) break;
        
        ++n;
    }
    
    for(int i=0;i<n;++i){
        cout<<"Case "<< i+1 << ": "<<x[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3048
#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 A,B;
  cin>>A>>B;
  if(B%A==0) cout<<B+A;
  else cout<<-A+B;
return 0;}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
bool comp(pair<double, long long> a, pair<double, long long> b) {
    return 1.0 * a.second / a.first < 1.0 * b.second / b.first;
}
 
int main() {
    ios::sync_with_stdio(false);
    pair<double, long long> cost[5];
    cost[1].first = 0.25;
    cost[2].first = 0.5;
    cost[3].first = 1.0;
    cost[4].first = 2.0;
    for (int i = 1; i <= 4; i++) {
        cin >> cost[i].second;
    }
    double n;
    cin >> n;
    sort(cost + 1, cost + 5, comp);
    long long res = 0;
    for (int i = 1; i <= 4; i++) {
        res += (int)floor(1.0 * n / cost[i].first) * cost[i].second;
        n -= (int)floor(1.0 * n / cost[i].first) * cost[i].first;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

double p[17][17];
double dp[17][1<<16];
int n,m;

double DFS(int idx, int state){
	if(idx == n)return 1.0;
	if(dp[idx][state] >= -0.1)return dp[idx][state];
	double ret = -0.1;
	REP(i,m){
		int mask = (1<<i);
		if(mask & state)continue;
		double ret1=0.0;
		double tmp =1.0;
		FOR(j, idx, n){
			ret1 += tmp*(1-p[i][j])*DFS(j, (state|mask));
			tmp *= p[i][j];
		}
		ret1+=tmp;
		ret = max(ret, ret1);
	}
	return dp[idx][state] = max(ret, 0.0);
}

int main(){
	scanf("%d%d", &m, &n);
	REP(i,m)REP(j,n)scanf("%lf", &p[i][j]);
	REP(i,n)REP(j,(1<<m))dp[i][j]=-1.0;
	printf("%.10f\n", DFS(0,0));
	return 0;
}

Measured memory_bytes: 9284
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


void solve()
{ 
  int a,b,c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << '\n';
 return;
}

signed main()
{
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int m[1001][1001];
int main()
{
  int n,i,j,k,c,d;
  char s[1001];
  for(;;){
    scanf("%d",&n);
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%s",s);
      c=0;
      for(j=0;j<n;j++){
	if(s[j] == '.') c++;
	else c=0;
	m[i][j] = c;
      }
    }
    c = 0;
    for(i=0;i<n;i++){
      for(j=n-1;j>=0;j--){
	if(m[i][j] > c){
	  d = m[i][j];
	  for(k=i+1;k<i+d;k++){
	    if(k >= n || m[k][j] < c) break;
	    if(d > m[k][j]) d = m[k][j];
	  }
	  if(k==i+d) c = d;
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int []a = new int [100*n+m];
			
			for(int b=0;b<n;b++){
				for(int c=0;c<m;c++){
					a[100*b+c] = sc.nextInt();
				}
			}
			
			int []b = new int[m];
			for(int c=0;c<m;c++){
				b[c] = sc.nextInt();
			}
			
			
			for(int d=0;d<n;d++){
				int x=0;
				for(int c=0;c<m;c++){
					x=x+a[100*d+c]*b[c];
				}
				System.out.println(x);
			}
	}
}

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

int main() {
    int N;
    cin >> N;
    if (N % 1000 == 0) cout << 0 << endl;
    else {
        for (int i=1; i<=10; i++) {
            if (1000*i - N > 0) { cout << 1000*i - N << endl; return 0; }
        }
    }
    return 0;
}


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


unsigned int val[500000];
unsigned int buf[500000];
int counter = 0;

void margeSort(int left, int right){
	int mid = (left + right) / 2;

	if(left == right) return;

	margeSort(left, mid);
	margeSort(mid + 1, right);

	for(int i = left; i <= mid; i ++){
		//cout << "val[" << i << "] = " << val[i] << endl;
		buf[i] = val[i];
	}
	
	for(int i = mid + 1; i <= right; i ++){
		//cout << "val[" << i << "] = " << val[i] << endl;
		buf[right - i + mid + 1] = val[i];
	}
	
	int rightCounter = right;
	int leftCounter = left;

	//cout << "==========compairsion is started=============" << endl;

	for(int i = left; i <= right; i ++){
		if(buf[leftCounter] <= buf[rightCounter]){
			//cout << "L is small:val[" << i << "] <-- " <<  "buf[" << leftCounter << "]:" <<  buf[leftCounter] << endl;	
			val[i] = buf[leftCounter];	
			leftCounter ++;
		}else{
			//cout << "R is small:val[" << i << "] <-- " <<  "buf[" << rightCounter << "]:" << buf[rightCounter] << endl;	
			val[i] = buf[rightCounter];
			rightCounter --;
		}
		counter ++;
	}
};


int main(){

	ios_base::sync_with_stdio(false);

	int number;
	cin >> number;
	int i = 0;
	while(cin >> number){
		val[i] = number; 
		i++;
	}

	margeSort(0 , i - 1);

	for(int j = 0; j < i; j++)
		cout << val[j] << (j + 1 < i  ? " ":"");
	
	cout << endl;
	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 5112
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

int n;
int in[105];
unsigned long long int pm(int now,int sum);
unsigned long long int memo[105][30];

main(){
  memset(memo,-1,sizeof(memo));

  cin >> n;
  for(int i=0;i<n;i++) cin >> in[i];
  cout << pm(0,0) << endl;

}

unsigned long long int pm(int now,int sum){
  if(now==n-1){
    if(sum==in[now]) return 1;
    else return 0;
  }

  if(memo[now][sum]!=-1) return memo[now][sum];

  if(now==0 && in[now]==0) return memo[now][sum]=pm(now+1,sum);

  if(sum+in[now]<=20){
    if(0<=sum-in[now]){
      return memo[now][sum]=pm(now+1,sum+in[now])+pm(now+1,sum-in[now]);
    }
    else return memo[now][sum]=pm(now+1,sum+in[now]);
  }
  else if(0<=sum-in[now]){
    return memo[now][sum]=pm(now+1,sum-in[now]);
  }

  return memo[now][sum]=0;

}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX 100005
 
/* UNION-FIND library */
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int main()
{
    int n, m, q, s, t;
 
    n = in(), m = in();
    init(n);
    while (m--) {
        s = in(), t = in();
        unite(s, t);
    }
     
    q = in();
    while (q--) {
        s = in(), t = in();
        puts(connected(s, t)? "yes": "no");
    }
    return 0;
}



Measured memory_bytes: 2308