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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;

/**
 * Library
 * --------------------------------------------------------
 */

/**
 * ワーシャルフロイド法
 * 隣接行列で受け取り、全頂点間最短経路を算出
 */
void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}
/**
 * --------------------------------------------------------
 */

/**
 * https://atcoder.jp/contests/abc073/submissions/7665203
 * ABC 073 D - joisino's travel
 */
void Main() {
    int H, W;
    cin >> H >> W;

    // vector<vector<int>> c(10, vector<int>(10));
    // rep(i, 10){rep(j, 10){int tmp; cin >> tmp; c[i].push_back(tmp);}}

    Graph graph(10, vector<ll>(10, INF));
    rep(i, 10) {
        rep(j, 10) {
            int tmp;
            cin >> tmp;
            graph[i][j] = tmp;
        }
    }
    warshall_floyd(graph);

    ll ans = 0;
    rep(i, H) {rep(j, W) {int a; cin >> a; if (a != -1){ans += graph[a][1];}}}
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


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

    int N,M,C;
    cin >> N >> M >> C;
    int B[M],A;
    int count = 0;
    int isGood;
    REP(i,M){
        cin >> B[i];
    }
    REP(i,N){
        isGood = 0;
        REP(j,M){
            cin >> A;
            isGood += A*B[j];
        }
        if(isGood+C > 0) count++;
    }

    cout << count << endl;

    

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int ans = 0;
	for(int i=1;i<=100;i++)
	{
	    bool h=0; int cc=0;
	    for(int j=0;j<n;j++)
	    {
	        if(!h)
	        {
	            if( a[j] >= i )
	            {
	                cc++; h = 1;
	            }
	        }
	        else
	        {
	            if( a[j] < i ) h = 0;
	        }
	    }
	    ans += cc;
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut sum = 0;
    for i in 1..=n {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i;
        }
    }

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


Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split(" ");
        int gate_num = Integer.valueOf(input[1]);

        int gate_min = Integer.MIN_VALUE;
        int gate_max = Integer.MAX_VALUE;

        for(int i = 0; i < gate_num; i++) {
            String[] allow_gate = scanner.nextLine().split(" ");
            int min = Integer.valueOf(allow_gate[0]);
            int max = Integer.valueOf(allow_gate[1]);

            if(min > gate_min) gate_min = min;
            if(max < gate_max) gate_max = max;
        }
        int ans = gate_max - gate_min + 1;
        if (ans < 0) ans = 0;

        System.out.println(ans);
    }
}


Measured memory_bytes: 90352
while True:
    s=raw_input()
    if s=="0":break
    L=[s]+[raw_input() for i in range(2)]
    L[0]=L[0][1:]+L[1][0]
    L[1]=L[1][1:]+L[2][0]
    L[2]=L[2][1:]
    for i in range(3):
        ca,cb=L[i].count("A"),L[i].count("B")
        if i<>2:
            print ca,cb
        else:
            if ca>cb:
                print ca+1,cb
            else:
                print ca,cb+1

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[k+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=k;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(a[j]<=i&&dp[i-a[j]]==0)
      {
        dp[i]=1;
      	break;
      }
    }
  }
  string res=dp[k]==1?"First":"Second";
  cout<<res<<endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int N, K;
	cin >> N >> K;
	ll wnum[4*K][4*K];
	REP(i, 4*K) REP(j, 4*K) wnum[i][j] = 0;
	ll x, y;
	char c;
	REP(i, N){
		cin >> x >> y >> c;
		if(c=='B') y += K;
		x %= (2*K);
		y %= (2*K);
		wnum[x][y]++;
		wnum[x+2*K][y]++;
		wnum[x][y+2*K]++;
		wnum[x+2*K][y+2*K]++;
	}

	ll swnum[4*K+1][4*K+1];
	REP(i, 4*K+1) swnum[i][0] = 0;
	REP(j, 4*K+1) swnum[0][j] = 0;
	REP(i, 4*K)REP(j, 4*K){
		swnum[i][j+1] = swnum[i][j] + wnum[i][j];
	}
	REP(j, 4*K)REP(i, 4*K){
		swnum[i+1][j] += swnum[i][j];
	}

	ll res = 0;
	ll tmp, tmp1, tmp2;
	REP(i, 2*K)REP(j, 2*K){
		tmp1 = swnum[i+K][j+K] - swnum[i][j+K] - swnum[i+K][j] + swnum[i][j];
		tmp2 = swnum[i+2*K][j+2*K] - swnum[i+K][j+2*K] - swnum[i+2*K][j+K] + swnum[i+K][j+K];
		tmp = tmp1 + tmp2;
		res = max(res, tmp);
	}
	cout << res << endl;

    return 0;
}

Measured memory_bytes: 250368
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b;
    cin >> a >> b;
    cout << a - (a > b ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define HASH_SIZE 65536

struct list {
    int val;
    int cnt;
    struct list *next;
};

struct list *create_htable(void) {
    static struct list htable[HASH_SIZE];
    int i;
    for(i = 0; i < HASH_SIZE; i++) {
        htable[i].next = &htable[i];
    }
    return htable;
}

int get_key(int val) {
    return val & (HASH_SIZE-1);
}

struct list* find(struct list *htable, int val) {
    struct list *head = &htable[get_key(val)];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        if(elem->val == val) {
            return elem;
        }
    }
    return NULL;
}

void add_elem(struct list *htable, int val) {
    struct list *elem = find(htable, val);
    struct list *head = &htable[get_key(val)];
    if(!elem) {
        // newly created
        elem = malloc(sizeof(struct list));
        elem->next = head->next;
        elem->val = val;
        elem->cnt = 0;
        head->next = elem;
    }
    elem->cnt++;
}

void put_elem(struct list *htable, int val) {
    struct list *elem = find(htable, val);
    // no way!!
    if(!elem) return;
    elem->cnt--;
}

#define NUM_MAX 200000

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    static int diff[NUM_MAX];

    fget_array(arr, num);
    int i;
    struct list *htable = create_htable();
    // a2 - h2 = h1 + a1 s.t. a1 < a2
    for(i = 0; i < num; i++) {
        // order - height
        diff[i] = (i+1) - arr[i];
        add_elem(htable, diff[i]);
    }

    int64_t ans = 0;
    for(i = 0; i < num; i++) {
        int sum = arr[i] + (i+1);
        put_elem(htable, diff[i]);
        // find within [i+1, num)
        struct list *elem = find(htable, sum);
        if(elem) ans += elem->cnt;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 10008
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll N;

void dfs(ll &ans, vl &Q, ll ind, vector<vector<pll>> xy){
  if(ind == N + 1){
    ll cnt = 0;
    
    rep2(i, 1, N + 1){
      cnt += Q[i];
      
      if(Q[i] != 1) continue;

      rep(j, xy[i].size()){
	if(Q[xy[i][j].first] != xy[i][j].second) return;
      }
    }

    ans = max(ans, cnt);
    
    return;
  }

  rep(i, 2){
    Q[ind] = i;
    dfs(ans, Q, ind + 1, xy);
  }

  return;
}

int main(){
  cin >> N;
  vector<vector<pll> > xy(N + 1);
  ll x, y, A;
  rep2(i, 1, N + 1){
    cin >> A;
    rep(j, A){
      cin >> x >> y;
      xy[i].push_back({x, y});
    }
  }

  vl Q(N + 1);
  Q[0] = 0;
  ll ans = -1;
  dfs(ans, Q, 1, xy);

  cout << ans << endl;
    
  return 0;
}


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

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

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


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
//		solveA(args);
		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int a = nextInt();
		pw.println(a+a*a+a*a*a);
	}
	public static void solveB(String[] args) throws Exception{
		String S = nextString();
		String T = nextString();

		int ans = 0;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)!=T.charAt(i)) {
				ans++;
			}
		}
		pw.println(ans);
	}
	public static void solveC(String[] args) throws Exception{

	}
	public static void solveD(String[] args) throws Exception{

	}
	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    int H,W;
    cin >> H >> W;

    string ans="";
    REP(i,H) REP(j,W){
        string s;
        cin >> s;

        if(s=="snuke"){
            ans = (char)('A'+j);
            ans += to_string(i+1); 
        }
    }
    
    pl(ans)

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S1 = list(input())
S2 = list(input())

MOD = 10**9 + 7
ans = []
skip = False
pre_tate = False
for u,l in zip(S1,S2):
    if skip == True:
        skip = False
        continue

    if len(ans) == 0:
        if u == l:
            ans.append(3)
            pre_tate = True
        else:
            ans.append(6)
            skip = True
            pre_tate = False
    else:
        if u == l:
            if pre_tate:
                ans.append(2)
            else:
                ans.append(1)
            pre_tate = True
        else:
            if pre_tate:
                ans.append(2)
            else:
                ans.append(3)
            skip = True
            pre_tate = False

tmp = 1
for a in ans:
    tmp *= a

print(tmp%MOD)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	int a[1005][1005];
	string ans = "No";
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++){
			a[i][j] = j*n+i*m-(i*j)-(i*j);
			if(a[i][j]==k){
				ans = "Yes";
			}
		}
	}
	cout << ans <<  endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

if len(S) == len(set(S)):
    print('yes')
else:
    print('no')


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

using namespace std;

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define endl "\n"

#define aim_cpo do{ios::sync_with_stdio(false);\
cin.tie(nullptr);cout.precision(10);cout<<fixed;}while(0)

#define LOCAL_INPUT do{FILE *stream1;\
stream1=freopen("/Users/aim_cpo/CLionProjects/competitive/in.txt","r",stdin);\
if(stream1==nullptr)return 0;}while(0)

#define LOCAL_OUTPUT do{FILE *stream2;\
stream2 = freopen("out.txt", "w", stdout);\
if (stream2 == nullptr) return 0;}while(0)

#ifdef LOCAL_DEFINE
#define show(x) cerr << #x << " = " << x << endl
#else
#define show(x)
#endif

typedef long long ll;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399

template <typename T> bool chmin(T &a, T b) {
    if (a > b) {a = b;return true;}return false;
}

template <typename T> bool chmax(T &a, T b) {
    if (a < b) {a = b;return true;}return false;
}

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return 1;
    return 0;
}

// MOD
const ll MOD = (ll)1e9 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

//LLの数値をつかう時は最後にLをつける癖をつけよう
//
//  ┏┓┏┓　┓　┏┓
//  ┏┛┃┃　┃　┗┫
//  ┗┛┗┛　┻　┗┛
//
//   謹┃賀┃新┃年┃
//   ━┛━┛━┛━┛
//WWWWWWWWWWWWWWWWWWWWWW

int n, m, w, k;
int a[101];
bool dp[2][100001];
bool past[2][100001];

bool memo(int who, int num) {
    if (past[who][num]) return dp[who][num];
    bool win = false;
    for (int i = 0; i < n; i++) {
        if (num >= a[i]) {
            if (memo(who ^ 1, num - a[i]) == who) win = true;
        }
    }
    if (win) {
        past[who][num] = true;
        dp[who][num] = (bool)who;
    } else {
        past[who][num] = true;
        dp[who][num] = (bool)(who ^ 1);
    }
    return dp[who][num];
}

int main() {
    aim_cpo; // インタラクティブのときは消すように.
#ifdef LOCAL_DEFINE
    LOCAL_INPUT; // インタラクティブのときは消すように.
//    LOCAL_OUTPUT; // ファイルに出力したいときのみ
    show(MOD);
#endif
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (memo(0, k)) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s." << endl;
#endif
    return 0;
}

Measured memory_bytes: 6912
mansions = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())

for l in range (n):
    a,b,c,d =input().split()
    mansions[int(a)-1][int(b)-1][int(c)-1] += int(d)


for i in range(4):
    if not i == 0:
        print()
        print("####################")
    for j in range(3):
        if not j == 0:
            print()
        for k in range(10):
            print(" ",end="")
            print(mansions[i][j][k],end="")
            if i == 3 and j == 2 and k == 9:
                print()


Measured memory_bytes: 5636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,sum,flag;
int main()
{
	scanf("%lld",&n);
	flag=0;
	sum=10000000000000;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			if(sum>i+(n/i))
			{
				sum=i+(n/i);
			}
		}
	}
	if(flag==1)
	{
		printf("%lld\n",sum-2);
	}
	else
	{
		printf("%lld\n",n-1);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] score = new int[2];
        while (n-- > 0) {
            String a = input.next();
            String b = input.next();
            int cmp = a.compareTo(b);
            if (0 < cmp) score[0] += 3;
            else if (cmp < 0) score[1] += 3;
            else {score[0]++; score[1]++;}
        }
        System.out.println(String.format("%d %d", score[0], score[1]));
    }
}

Measured memory_bytes: 20828
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    #city = []
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = int(p)
        sp.append([s, p, i])
        city.add(s)
    city = list(city)
    city.sort()
    ans = [[] for i in range(len(city))]
    sp.sort(reverse=True, key=lambda x: x[1])
    for s, p, i in sp:
        for j, c in enumerate(city):
            if s == c:
                ans[j].append(i)

    for a in ans:
        print(*a, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
#include <random>
using namespace std;

int main() {
    int n = 0, k = 0;
    cout << fixed << setprecision(15);
    cin >> n;
    cin >> k;

    double sumN = 0.;
    for (int i = 1; i <= n ; ++i) {
        double diceP = 1.0 / n;
        for (int j = i; j < k ; j*=2) {
            diceP /= 2;
        }
        sumN += diceP;
    }

    cout << sumN << endl;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	ll ans = 0;
	rep1(i, n) if(i % 3 && i % 5) ans += i;
	print(ans);
}


Measured memory_bytes: 3660
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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; }

ll N,A,B;

bool check(ll T,vector<ll> h){
    ll mid = T;
    ll base_damage = B*mid;
    ll count=0;
    for(ll i=0;i<N;i++){
        if(h[i]<=B*mid)continue;
        count+=ceil((double)(h[i]-base_damage)/(double)(A-B));
    }
    return count>mid;
}
int main(){
    cin>>N>>A>>B;
    vector<ll> h(N);
    for(ll i=0;i<N;i++){
        cin>>h[i];
    }
    ll right = 2e9;
    ll left = 0;
    while(left<=right){
        ll mid = left+(right-left)/2;
        bool ok = check(mid,h);
        if(ok){
            left = mid+1;
        }else{
            right = mid-1;
        }
        // cout<<"left:"<<left<<", right:"<<right<<endl;
    }
    cout<<left<<endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  string w;
  cin >> w;
  map<char, int> cnt;
  REP(i, w.size()){
    cnt[w[i]]++;
  }
  for(auto it=cnt.begin(); it != cnt.end(); it++){
    if(it->second % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
vector<ll> A;
bool able = false;
ll UPPER = 1000000000000000000;

int main(){
    cin >> N;
    ll a;
    for(int i = 0; i < N; i++){
        cin >> a;
        if(a == 0){ able = true; break; }
        A.push_back(a);
    }
    
    if(able) cout << 0 << endl;
    else {
      for(int i = 0; i < N; i++){
          UPPER = UPPER / A[i];
      }

      if(UPPER > 0){  //0省き
        ll res = 1;
        for(int i = 0; i < N; i++) res *= A[i];
        cout << res << endl;
      } else cout << -1 << endl;

  }

    return 0;

}

Measured memory_bytes: 4300
#include <stdio.h>
#include <math.h>
#define MAX 1000000
//エラトステネスの篩
int main(){
    int mem[100000] = {2};
    bool list[MAX]={true,true};
    int set = 2,m = 1,j,x;
    while( set < sqrt( MAX )){
    	for( int i = set;i < MAX;i++ ) if( i % set == 0 ) list[i] = true;
    	for( int i = set;i < MAX;i++ ) if( list[i] == false ){ set = i,mem[m++] = i,list[i] = true;break; }
    }
    for( int i = set;i < MAX;i++ )if( list[i] == false ) mem[m++] = i;
    while( scanf( "%d",&x ) != EOF ){
        for( j = 0;mem[j] <= x && j < m;j++ );
        printf( "%d\n",j );
    }
    return 0;
}

Measured memory_bytes: 2400
#include <cstdio>

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  printf("%d\n", max(min(b, d) - max(a, c), 0));
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '2'){
            count++;
        }
    } 
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define nmax_def 110000
#define mod 2019
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int L, R;
	int ans = 10000;
	int over0;
	cin >> L >> R;
	over0 = (R / mod) - (L / mod);
	if (over0 >= 1)
		ans = 0;
	else
	{
		L %= mod;
		R %= mod;
		for (i = 0; i < mod; i++)
		{
			for (j = i + 1; j < mod; j++)
			{
				if (i >= L && j <= R)
				{
					ans = min(ans, (i * j) % mod);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int x,y;

signed main() {
  cin >> x >> y;

  rep(a, x+1) rep(b, x+1) {
    if(a+b != x) continue;
    if(y==2*a + 4*b) {puts("Yes"); return 0;}
  }
  puts("No");
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N;

int main(){
    cin>>N;
    out(((N+1))/2/double(N));
    
}


Measured memory_bytes: 256
#include<iostream>
#define ll unsigned long long int
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	ll ans=k;
	for(int i=0;i<n-1;i++)
	{
		ans*=k-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    //input
    int h,w;cin >> h >> w;
    vector<string> str(h);
    for(int i = 0; i < h; i++) cin >> str[i];
    vector<vector<int>> a(h, vector<int>(w));
    vector<vector<int>> b(h + 2, vector<int>(w + 2));
    vector<vector<int>> c(h + 2, vector<int>(w + 2));

    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
           a[i][j] = 0;
        } 
    }
  
    for(int i = 0;i < h + 2; i++) {
        for(int j = 0; j < w + 2 ; j++){
           b[i][j] = 0;
           c[i][j] = 0;
        } 
    }  

    //compute
    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
            if(str[i].at(j) == '#'){
                b[i + 1][j + 1] = 1;
            }    
        } 
    }

    for(int i = 0;i < h; i++) {
        for(int j = 0; j < w ; j++){
            if(b[i + 1][j + 1] == 0){
                c[i + 1][j + 1] += b[i][j]+b[i][j + 1]+ b[i][j + 2];
                c[i + 1][j + 1] += b[i + 1][j] + b[i + 1][j + 2];
                c[i + 1][j + 1] += b[i + 2][j] + b[i + 2][j + 1] + b[i + 2][j + 2];
            }else{
                c[i + 1][j + 1] = 100;
            }
        }
    } 

    //output
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(c[i + 1][j + 1] == 100){
                cout << '#';
            }else{
                cout << c[i + 1][j + 1];
            }
            if(j == w - 1){
                cout << endl;
            }
        }
    }    

}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int A;
    cin>>A;
    for(int i=1;i<10;i++){
        if((A%i==0)&&(A/i<10)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s[50]; int t[50];
string x;

int main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> s[i] >> t[i];
	cin >> x;
	
	rep(i, n) if (s[i] == x) break;
	
	int id = i;
	int ans = 0;
	for (i = id + 1; i < n; i++) ans += t[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0, 0]
A.extend(list(map(int, input().split())))
Buka = [[]for i in range(N+1)]

for i in range(2, len(A)):
    Buka[A[i]].append(i)

for i in range(1, len(Buka)):
    print(len(Buka[i]))


Measured memory_bytes: 113780
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
data = [list(map(int, input().split())) for _ in range(M)]

aMIN = min(a)
bMIN = min(b)

MIN = aMIN + bMIN

for k in data:
    MIN = min(MIN, a[k[0]-1]+b[k[1]-1]-k[2])


print(MIN)

Measured memory_bytes: 38508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

long long a, b, c, x, y;

signed main() {
	cin >> a >> b >> c >> x >> y;
	if (c * 2 <= a + b) {
		if (x > y) {
			if (a >= c * 2) {
				cout << c * (x * 2) << endl;
				return 0;
			}
			cout << c * (y*2) + a * (x - y) << endl;
			return 0;
		}
		else {
			if (b >= c * 2) {
				cout << c * (y * 2) << endl;
				return 0;
			}
			cout << c * (x*2) + b * (y - x) << endl;
			return 0;
		}
	}
	else {
		cout << a * x + b * y << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int i,j,x,isprime[200020]={};
    scanf("%d",&x);
    for(i=2; i<=200000; i++){
        isprime[i]=1;
    }
    for(i=2; i<500; i++){
        if(isprime[i]){
            for(j=2; j*i<=200000; j++){
                isprime[i*j]=0;
            }
        }
    }
    for(i=2; i<=200000; i++){
        if(isprime[i]==1 && i>=x){
            printf("%d",i);
            return 0;
        }
    }
}

Measured memory_bytes: 2480
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <vector <int> > vvi;
typedef vector <vector <ll> > vvl;
typedef vector <pair<int,int> > vii;
typedef vector <pair<ll,ll> > vll;

string itos(int n) {stringstream ss;ss<<n;string s=ss.str();return s;}

ll ppow(ll x,ll y,ll mod) {
    ll res=1;
    while(y) {
        if(y&1) res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

struct sk{
    int x,y,p;
};

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int c1,c2,m;
    cin >> c1 >> c2 >> m;
    vi a(c1),b(c2);
    vector<sk> c(m);
    int mn1=1000000,mn2=1000000;
    for (int i=0;i<c1;++i) {
        cin >> a[i];
        mn1=min(mn1,a[i]);
    }
    for (int i=0;i<c2;++i) {
        cin >> b[i];
        mn2=min(mn2,b[i]);
    }
    int ans=mn1+mn2;
    for (int i=0;i<m;++i) {
        cin >> c[i].x >> c[i].y >> c[i].p;
        c[i].x--,c[i].y--;
        ans=min(ans,a[c[i].x]+b[c[i].y]-c[i].p);
    }
    cout << ans;
}


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

using namespace std;
#define ll long long
#define ld long double

ll binPow(ll a, ll b) {
    ll ans = 1;
    while(b > 0) {
        if(b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

ll binPowMod(ll a, ll b, ll m) {
    ll ans = 1;
    a %= m;
    while(b > 0) {
        if(b & 1) ans *= a % m;
        a *= a % m;
        b >>= 1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    for(int i=0;i<n-k;i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int N,A,B,sum;
    scanf("%d",&N);
    if(N==1)
    {
        printf("Hello World");
    }
    else if(N==2)
    {
       scanf("%d%d",&A,&B);
        sum=A+B;
        printf("%d",sum);

    }

}


Measured memory_bytes: 128
io = STDIN
n=io.gets.to_i
V=io.gets.split.map(&:to_i)
even=Hash.new{|h,k|h[k]=0}
odd=Hash.new{|h,k|h[k]=0}
V.each_with_index do |v,i|
  if i.even?
    even[v]+=1
  else
    odd[v]+=1
  end
end
ev=even.sort_by{|h,v|v*-1}
od=odd.sort_by{|h,v|v*-1}
if ev.size==1 &&
   od.size==1
   if ev[0][0]==od[0][0]
     puts n/2
   else
     puts 0
   end
elsif ev.size==1 &&
   od.size!=1
   if ev[0][0]==od[0][0]
     puts n/2-od[1][1]
   else
     puts n/2-od[0][1]
   end
elsif ev.size!=1 &&
   od.size==1
   if ev[0][0]==od[0][0]
     puts n/2-ev[1][1]
   else
     puts n/2-ev[0][1]
   end
else
  if ev[0][0]==od[0][0]
    if ev[0][1]==od[0][1]
      if ev[1][1]==od[1][1]
        puts n-ev[0][1]-od[1][1]
      elsif ev[1][1]>od[1][1]
        puts n-ev[1][1]-od[0][1]
      else
        puts n-ev[0][1]-od[1][1]
      end
    elsif ev[0][1]>od[0][1]
      puts n-ev[0][1]-od[1][1]
    else
      puts n-ev[1][1]-od[0][1]
    end
  else
    puts n-ev[0][1]-od[0][1]
  end
end


Measured memory_bytes: 20496
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	string s;
	cin >> s;
	bool r1 = 0,r2 = 0;
	rep(i,0,s.size()-1){
		if(s[i] == 'A') r1 = 1;
		else r2 = 1;
	}
	if(r1&&r2) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (H, W) = read!(usize, usize);
    let S = read![String; H]
        .into_iter()
        .map(|S| S.chars().collect::<Vec<_>>())
        .collect::<Vec<_>>();

    // row[y][x] = yn : 位置 y, x に置くと同じ行の他の yn マスが照らされる
    let mut row = vec![vec![0; W]; H];

    for y in 0..H {
        let mut n = 0;
        let mut l = 0;
        for x in 0..W + 1 {
            if x == W || S[y][x] == '#' {
                for xx in l..x {
                    row[y][xx] = n;
                }
                n = 0;
                l = x + 1;
                continue;
            }

            n += 1;
        }
    }

    let mut col = vec![vec![0; W]; H];

    for x in 0..W {
        let mut n = 0;
        let mut l = 0;
        for y in 0..H + 1 {
            if y == H || S[y][x] == '#' {
                for yy in l..y {
                    col[yy][x] = n;
                }
                n = 0;
                l = y + 1;
                continue;
            }

            n += 1;
        }
    }

    let mut M = 0;
    for y in 0..H {
        for x in 0..W {
            M = max(M, row[y][x] + col[y][x] - 1);
        }
    }

    println!("{}", M)
}


Measured memory_bytes: 53500
#include <iostream>
#include <vector>
#include <queue>
/**
 * 最短路の復元
 * 入口を0,隣を1,その隣を2・・・というように番号を振ったBFS木と考える　
 * */

const int  INF =  1001001001;

std::vector<int> to[1000005];   //  to[v]には、部屋vにつながっている部屋のリストが保持される
int main()
{
    // data 
    int N, M;
    std::cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        int a, b;
        std::cin >> a >> b;
        --a;--b;    // インデックスにするので-1しとく 
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    // execute  
    std::queue<int> searchMemo;             // 探索したい部屋を記録するキュー 
    std::vector<int> nextRoom(N, INF);    // 2~Nの部屋の番号 INFならまだ見ていない 
    std::vector<int> dist(N, -1);
    int roomCnt = 0;    // 全ての部屋がに番号がついたか？ 

    searchMemo.push(0); // 最初の部屋から始める 
    dist[0] = 0;        // 最初の部屋の距離を初期化 
    roomCnt++;
    
    // 探したい部屋がなくなるまで 
    while(!searchMemo.empty())
    {
        int searchingRoom = searchMemo.front();
        searchMemo.pop();

        for(int neighbor : to[searchingRoom])
        {
            // まだ番号のない部屋か？ 
            if(dist[neighbor] == -1)
            {
                dist[neighbor] = dist[searchingRoom] + 1;
                nextRoom[neighbor] = searchingRoom;
                searchMemo.push(neighbor);  // 隣であることがわかった部屋を次の周回で探す 
                roomCnt++;
            }
        }
    }

    if(roomCnt != N)
    {
//        std::cout << roomCnt;
        std::cout << "No" << std::endl;
        return 0;
    }else
    {
        std::cout << "Yes" << std::endl;
    }

    for(int i = 1; i < N; i++)
    {
        int ans = nextRoom[i] + 1;
        std::cout << ans << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 31756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a;
  a = 0;
  in(n);
  vector<ll> c(n), b(n, 0);
  rep(i, n){
    in(c[i]);
    if(c[i] == i + 1)
      b[i]++;
  }
  rep(i, n - 1){
    if(b[i] == 1){
      b[i]--;
      a++;
      b[i + 1]--;
    }
  }
  if(b[n - 1] == 1)
    a++;
  out(a);
  memi;
}

Measured memory_bytes: 1792
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import math
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
      ]
  k = int(input())
  print(l[k-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 38256
def main():
    import sys
    input=sys.stdin.readline
    H,W=map(int,input().split())
    maze=[]
    for _ in range(H):
        s=input().rstrip()
        maze.append(s)
    lamp=[[0]*W for _ in range(H)]
    for i in range(H):
        num=0
        for j in range(W):
            if maze[i][j]=="#":
                for k in range(1,num+1):
                    lamp[i][j-k]=num
                num=0
            else:
                num+=1
                if j==W-1:
                    for k in range(num):
                        lamp[i][j-k]=num
    for i in range(W):
        num=0
        for j in range(H):
            if maze[j][i]=="#":
                for k in range(1,num+1):
                    lamp[j-k][i]+=num
                num=0
            else:
                num+=1
                if j==H-1:
                    for k in range(num):
                        lamp[j-k][i]+=num
    lamp=[i for j in lamp for i in j]
    print(max(lamp)-1)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 216584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    //愚直にやったら間に合う?
    string s;
    cin>>s;
    int n = s.length();
    int fb=1;
    int64_t q;
    cin>>q;
    rep(i,q){
        int t;
        cin>>t;
        if(t==1){
            fb *= -1;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){//先頭にciを追加
                if(fb==1){
                    s.insert(s.begin(),c);
                }
                else{
                    s.push_back(c);
                }
            }
            else{//f==2 => 末尾にcを追加    
                if(fb==1){
                    s.push_back(c);
                }
                else{
                    s.insert(s.begin(),c);
                }
            }
        }
    }
    if(fb==1){
        rep(i,s.length()){
            cout<<s[i];
        }
    }
    else{
        for(int i=s.length()-1;i>=0;i--){
            cout<<s[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 1028