akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	s := r.nextString()

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(s[:n/2] == s[n/2:])])
}


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

int main() {
    string s;
    cin >> s;
    
    vector<int> a(26);
    for (int i = 0; i < s.size(); i++) a[s[i]-'a']++;
    
    for (auto& e : a) {
        if (e >= 2) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a + b == 15 )
		printf("+\n");
	else if (a * b == 15)
		printf("*\n");
	else
		printf("x\n");
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

int solve(void);

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

int solve(void)
{
	ll A, B, K;
	cin >> A >> B >> K;

	B = max(0LL, B - max(0LL, K - A));
	A = max(0LL, A - K);
	
	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define vl vector<long long>
#define pll pair<long long,long long>
#define sl set<long long>
#define uset unordered_set<long long>
#define umap unordered_map
#define hell 1000000007
#define mod 998244353
#define pb push_back
#define mp make_pair
#define N 10001
#define inf 1e16
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<endl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
using namespace std;
ll power(ll x, ll y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return (power(x, y / 2) * power(x, y / 2)) % mod;
  else
    return ((x * power(x, y / 2)) % mod * power(x, y / 2)) % mod;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;  
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p; 
}
int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt.txt","r",stdin);
  freopen("output.txt.txt","w",stdout);
  freopen("error.txt","w",stderr);
  #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,k,s=0,i;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n);
    for(i=0;i<k;i++)
      s+=a[i];
    cout<<s;

    cerr<<(1000*clock())/CLOCKS_PER_SEC<<"ms";
    return 0;
}


Measured memory_bytes: 3664
n,a,b = [int(i) for i in input().split()]

#n is the point in which to check wheter the mark is different
def f(n,a,b):
    if n==1:
        return [a,b]

    mask = 1<<(n-1)

    #if biggest bit of a == that of b
    if a & mask == b & mask:
        v1 = f(n-1, a, b)
        v2 = f(n-1, a^mask, v1[1]^mask)
        ret = [a]
        ret.extend(v2)
        ret.extend(v1[1:])
        return ret        
    else:
        # biggest bit of a and b is different
        v1 = f(n-1, a, a^1)
        v2 = f(n-1, a^1^mask, b)
        v1.extend(v2)
        return v1



#exclusive or
if bin(a^b).count("1") %2==0:
    print("NO")
else:
    print("YES")
    res = f(n,a,b)
    for p in res:
        print(p, end=" ")


Measured memory_bytes: 9884
n, m = map(int, input().split())
cnt = [0] * (n + 1)
for _ in range(m):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1
for i in cnt:
    if not i % 2 == 0:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 9660
#include <iostream>

using namespace std;

int main(void){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> c[i][j];
    }
  }
  for(int i = 0;i < h;i++){
    for(int k = 0;k < 2;k++){
      for(int j = 0;j < w;j++){
        cout << c[i][j];
        if(j == w-1){
          cout << "\n";
        }
      }
    }
  }
}


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

int main(){
  int x,y;
  cin >> x >> y;

  int ans = 0;
  if(x<=3) ans+=(4-x)*100000;
  if(y<=3) ans+=(4-y)*100000;
  if(x+y==2) ans+=400000;

  cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by pavao on 9/22/2019.
//

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> scores(n, 0);
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        scores[t - 1]++;
    }
    for (int i = 0; i < n; i++) {
//        cout << scores[i] << " " << k - (q - scores[i]);
        if (k - (q - scores[i]) <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> pix(H + 2, vector<char>(W + 2, '#'));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> pix.at(i+1).at(j+1);
        }
    }
    for(int i = 0; i < H+2; i++){
        for(int j = 0; j < W+2; j++){
            cout << pix.at(i).at(j);
            if(j == W + 1) cout << endl;
        }
    }
}


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e18;

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

  set<char> se;
  for (char a = 'a'; a <= 'z'; a++) {
    se.insert(a);
  }

  each(c, s) { se.erase(c); }
  if (se.size()) {
    cout << s + *se.begin() << endl;
    return 0;
  }

  for (int i = s.size() - 2; i >= 0; i--) {
    if (s[i] < s[i + 1]) {
      char mx = 'z' + 1;
      for (int j = i + 1; j < s.size(); j++) {
        if (s[i] < s[j]) {
          mx = min(mx, s[j]);
        }
      }
      if (mx == 'z' + 1) {
        for (int j = i + 1; j < s.size(); j++) {
          mx = min(mx, s[j]);
        }
      }
      cout << s.substr(0, i) + mx << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int h,w;
string s[30][30];

int main(){
  cin>>h>>w;
  rep(i,h){
    rep(j,w){
      cin>>s[i][j];
    }
  }

  char ansh;
  int answ;

  rep(i,h){
    rep(j,w){
      if(s[i][j]=="snuke"){
        ansh=(char)(j+'A');
        answ=i+1;
      }
    }
  }
  
  cout<<ansh<<answ<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll n,a,b;
  cin>>n>>a>>b;
  if( n==1 && a!=b ) return cout<<0<<endl,0;
  if( a>b ) return cout<<0<<endl,0;
  cout<<(n-1)*b+a-((n-1)*a+b)+1<<endl;
}


Measured memory_bytes: 256
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]


def solve(i):
    curStation = i
    ans = CSF[curStation][1]
    while curStation < N-1:
        if ans >= CSF[curStation][1]:
            t = (ans - CSF[curStation][1]) // CSF[curStation][2]
            if (ans - CSF[curStation][1]) % CSF[curStation][2] == 0:
                ans = CSF[curStation][1] + CSF[curStation][2] * t
            else:
                ans = CSF[curStation][1] + CSF[curStation][2] * (t+1)
        else:
            ans = CSF[curStation][1]
        ans += CSF[curStation][0]
        curStation += 1
        if curStation == N-1:
            break
    return ans


for i in range(N):
    if i == N-1:
        print(0)
    else:
        print(solve(i))

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

void resByBool(bool a){
    if(a)cout << "Yes";
    else cout << "No";
    cout << endl;
}

string arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    string s;
    cin >> s;
    ll k;
    cin >> k;
    
    ll cnt = 0;
    string s2 = s;
    string s3 = s;
    string s4 = s;
    ll cnt2=0;
    rep2(i, 1, s.length()){
        if(s[i] == s[i-1]){
            s[i] = 'A';
            s[i-1] = 'A';
            cnt2++;
        }
    }
    s2 = s + s2;
    rep2(i, 0, s2.length()){
        if(s2[i] == s2[i-1] && s2[i] != 'A'){
            s2[i] = 'A';
            s2[i-1] = 'A';
            cnt++;
        }
    }
    s3 = s2 + s3;
    ll cnt3 = 0;
    rep2(i, 0, s3.length()){
        if(s3[i] == s3[i-1] && s3[i] != 'A'){
            s3[i] = 'A';
            s3[i-1] = 'A';
            cnt3++;
        }
    }
    
    s4 = s3 + s4;
    ll cnt4 = 0;
    rep2(i, 0, s4.length()){
        if(s4[i] == s4[i-1] && s4[i] != 'A'){
            s4[i] = 'A';
            s4[i-1] = 'A';
            cnt4++;
        }
    }
    
    if(k == 1){
        cout << cnt2;
    }
    else if(k == 2){
        cout << cnt2 + cnt * (k-1);
    }
    else if(k==3){
        cout << cnt2 + cnt * (k/2) + cnt3 * (k/3);
    }
    else{
        ll ans =cnt2 + cnt + cnt3 * ((k-2)/2) + cnt4 * (k/2);
        cout << cnt2 + cnt + cnt3 * ((k-1)/2) + cnt4 * ((k-2)/2);
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a,b,c,d;
  	a=sc.nextInt();
  	b=sc.nextInt();
  	c=sc.nextInt();
  	
  	d=a;
  	a=b;
  	b=d;
  	d=a;
  	a=c;
  	c=d;
  	System.out.print(a+" "+b+" "+c);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#define max(a,b) (a>b)?a:b
int judge(char h);
int main(){
  char S[10];
  int i,j;
  int tm=0,m=0;

  scanf("%s",S);

  for(i=0;S[i]!='\0';i++){
    if(judge(S[i])){
      tm++;
    }else{
      if(tm>m)m=tm;
      tm=0;
    }
  }
  printf("%d\n",max(m,tm));

  return 0;
}

int judge(char h){
  char P[]="ACGT";
  for(int i=0;i<4;i++)if(h==P[i])return 1;
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int N;
    char S[10001];

    scanf("%d%s", &N, S);

    for(int i = 0; S[i] != '\0'; i ++){
        printf("%c", (S[i] + N - 65) % 26 + 65);
    }
    printf("\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  int M, D;
  cin >> M >> D;
  int64_t ans = 0;
  for(int i=4;i<=M;i++){
    for(int j=2;j<=D;j++){
      int S1 = j%10;
      int T1 = j/10;
      if(S1 == 0 || S1 == 1 || T1 == 0 || T1 == 1){
        continue;
      }
      if(i == S1 * T1){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>

using namespace std;
 
int main(){
 
int a,b; 
int A;
  
cin>>a>>b;
  
if(a < b || a == b){
for(int i = 0; i < b; i++){
  A += a * pow(10, i);
}  
}else{
for(int i = 0; i < a; i++){
  A += b * pow(10, i);
}
}

cout << A << endl;
  
}

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



int main() {

	int n;
	cin >> n;

	int t, a;
	cin >> t >> a;


	int h[1001];
	int min = 10000000;
	int ans = -1;

	for (int i = 0; i < n; i++) {
		cin >> h[i];
		int near = abs(1000 * t - h[i] * 6 - 1000 * a);

		if (near < min) {
			ans = i;
			min = near;
		}

	}

	ans++;

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	while(lines.shift() != "0"){
		var list = lines.shift().split(" ").map(Number);
		var ave = list.reduce(function(a,b){return a+b;}) / list.length;
		console.log(Math.sqrt(list.map(function(s){return Math.pow(s-ave,2)}).reduce(function(a,b){return a+b})/list.length));
	}
}

Measured memory_bytes: 16212
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll R, G, B, N; cin >> R >> G >> B >> N;
    ll res = 0;
    for (int i = 0; i <= N / R; i++) {
        for (int j = 0; j <= N / G; j++) {
            int left = N - i * R - j * G;
            if (left >= 0 && left % B == 0) {
//                printf("%d %d %d\n", i, j, left / B);
                res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n;
    double a;
    vector<double> v;
    cin >> n;
    fr(i, 0, n) {
        cin >> a;
        v.pb(a);
    }

    vector<double> p(n + 2, 0);
    vector<vector<double>> dp(n + 2, p);
    // dp[i][j]  = till ith coin j number of heads
    dp[0][0] = 1 - v[0];
    dp[0][1] = v[0];
    for (lli i = 1; i < n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - v[i]);
        for (lli j = 1; j <= n; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - v[i]) + dp[i - 1][j - 1] * v[i];
        }
    }

    double ans = 0;
    for (lli j = n / 2 + 1; j <= n; j++) {
        ans += dp[n - 1][j];
    }

    cout << fixed << setprecision(10) << ans << endl;
    // cout << ans << endl;
    rt;
}


Measured memory_bytes: 70784
#3問目
KT = input().split()
K,T = int(KT[0]), int(KT[1])
A = input().split()
intA = [int(s) for s in A]
saidai_i = 0
saidai = 0
withoutSaidaiSum = 0
for i in range(len(intA)):
    if(saidai < intA[i]):
        saidai = intA[i]
        saidai_i = i
for i in range(len(intA)):
    if(i != saidai_i):
        withoutSaidaiSum += intA[i]
print(max(0, saidai-withoutSaidaiSum-1))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int a,b;
	cin >> a >> b;
	if(a == b){
		for(int i = 0; i < a; ++i)cout << b ;
	}else{
		int c = min(a,b);
		int d = max(a,b);
		for(int i = 0; i < d; ++i){
			cout << c ;
		}
	}
	cout << endl;
}

int32_t main(){
	IO;
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 import static java.util.stream.Collectors.toList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		String s = sc.next();
		int maxLength = 0;
		int tempLength =0;

		for(int i=0;i<s.length();i++){
			String ss = s.substring(i,i+1);
			if(isContain(ss)){
				tempLength++;
			}else{
				maxLength =Math.max(tempLength,maxLength);
				tempLength =0;
			}
		}
		maxLength =Math.max(tempLength,maxLength);
			System.out.println(maxLength);
 
	}

	public static boolean isContain(String n){
		if(n.equals("A")){
			return true;
		}else if(n.equals("G")){
			return true;
		}else if(n.equals("C")){
			return true;
		}else if(n.equals("T")){
			return true;
		}
		return false;
	}
}




Measured memory_bytes: 23252
#!/usr/bin/env python3
#EDPC L

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
dp = [[0]*(n+1) for _ in range(n+1)]
for l in range(n)[::-1]:
    for r in range(l+1,n+1):
        if (n - (r-l)) % 2 == 0:
            dp[l][r] = max(dp[l+1][r] + a[l],dp[l][r-1] + a[r-1])
        else:
            dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1])
print(dp[0][-1])

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

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

    ll n;
    cin >> n;

    if(n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    for(ll i = 10; i <= n; i *= 5){
        ans += n / i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-max
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// max-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=max(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return 0; // max
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return max(lv,rv); // max
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmax(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};
 
int main() {
  ll n;
  cin >> n;
  vec h(n),a(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  for(ll i=0;i<n;i++) cin >> a[i];
  segtree T(n+1);
  T.Set(0,n,0);
  for(ll i=0;i<n;i++) {
    T.Set(h[i],h[i]+1,T.Getmax(0,h[i]+1)+a[i]);
  }
  cout << T.Getmax(0,n+1) << endl;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll L; cin >> L;
  long double x = L / 3.0;
  cout << x * x * x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

const int N = 100005;

ll dp[N];

int main(){
    IOS
    
    int n,W;
    cin>>n>>W;
    int w[n+1],v[n+1];
    ll sum=0;
    FOR(i,1,n+1){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    FOR(i,0,sum+1){
        dp[i]=MOD;
    }
    dp[0]=0;
    FOR(i,1,n+1){
        ROF(j,sum,v[i]){
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    ROF(i,sum,0){
        if(dp[i]<=W){
            cout<<i;
            return 0;
        }
    }
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())
s = [input() for i in range(H)]

flag = False
for i in range(1, H-1):
    for j in range(1, W-1):
        if s[i][j] == "#" and (s[i-1][j] == s[i+1][j] == s[i][j-1] == s[i][j+1] == "."):
            print("No")
            flag = True
            break
    if flag:
        break
else:
    print("Yes")

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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0;i < N;i++){
    int l , r;
    cin >> l >> r;
    sum += r - l;
    sum++;
  }
  cout << sum << endl;
}
  

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

int main()
{
    string db[110];
    int H, W;
    cin >> H >> W;
    char tmp;
    REP(i, H) cin >> db[i];

    REP(i, W + 2) cout << "#";
    cout << endl;
    REP(i, H)
    {
        cout << "#";
        REP(j, W)
        {
            cout << db[i][j];
        }
        cout << "#" << endl;
    }
    REP(i, W + 2) cout << "#";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, M, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    def is_ok(bcount):
        return Asum[acount] + Bsum[bcount] <= K


    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    nowtime = 0

    Asum = [0]
    Bsum = [0]
    tmp = 0
    for a in A:
        tmp += a
        Asum.append(tmp)
    tmp = 0
    for b in B:
        tmp += b
        Bsum.append(tmp)

    maxbooks = 0
    before = M
    ans = 0
    for acount in range(N+1):
        maxB = meguru_bisect(M+1, -1)
        if maxB < 0:
            continue
        ans = max(ans, acount+maxB)

    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 140320
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int keisan = 0;
		int sosu = 0;
		boolean tf = true;
		for(int i=0;i<times;i++){
			num[i] = scan.nextInt();
		}

		for(int i=0;i<times;i++){
			tf = true;
			if(num[i] == 2 || num[i] % 2 == 0){
				tf = false;
			}
			int ii=3;
			while (ii <= Math.sqrt(num[i])){
				if(num[i] % ii == 0){
					tf = false;
				}
				ii += 2;
			}
			if (num[i] == 2){
				tf = true;
			}
			if(tf == true){
				sosu +=1;
			}
		}
		System.out.println(sosu);
	}
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,x,t;
    cin>>n>>x>>t;
    
    if(n%x==0){
        cout<<(n/x)*t<<endl;
    }
    else{
        cout<<((n/x)+1)*t<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
<?php
  
  list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));

  if($a == $b){
    if($a != $c){
      echo "Yes";
      exit;
    }
  }
  if($a == $c){
    if($a != $b){
      echo "Yes";
      exit;
    }
  }
  if($b == $c){
    if($a != $c){
      echo "Yes";
      exit;
    }
  }
echo "No";



Measured memory_bytes: 4604
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	//int n; cin >> n;
	string s; cin >> s;
	int co[3] = {};
	REP(i, s.size()) co[s[i] - 'a']++;
	if (max({co[0], co[1], co[2]}) - min({co[0], co[1], co[2]}) <= 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

ll mod=998244353;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}

struct perm{
private:
	int sz;
	vector<ll> p,invp;
public:
	perm(int n){
		sz=n+1;
		p.resize(sz),invp.resize(sz);
		p[0]=1;
		for(int i=1;i<=sz-1;i++){
			p[i]=p[i-1]*i%mod;
		}
		invp[sz-1]=mod_pow(p[sz-1],mod-2);
		for(int i=sz-2;i>=0;i--){
			invp[i]=invp[i+1]*(i+1)%mod;
		}
	}
	ll comb(ll x,ll y){
		if(x<y||y<0)return 0;
		return (p[x]*invp[x-y]%mod)*invp[y]%mod;
	}
};
perm p(5000000);

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,m; cin >> n >> m;
	ll ans=0;
	for(int i=0;i<=min(n,m);i++){
		if((3*m-i)%2)continue;
		ll k=(3*m-i)/2;
		(ans+=p.comb(n,i)*p.comb(n-1+k,k)%mod)%=mod;
	}
	ll res=0;
	ll res2=0;
	for(int i=0;i<=(m,n);i++){
		if((m-i)%2)continue;
		ll k=(m-i)/2;
		(res+=p.comb(n,i)*p.comb(n-1+k,k)%mod)%=mod;
	}
	for(int i=0;i<=(m,n-1);i++){
		if((m-i)%2)continue;
		ll k=(m-i)/2;
		(res2+=p.comb(n-1,i)*p.comb(n-2+k,k)%mod)%=mod;
	}
	res-=res2;
	res%=mod;
	ans-=res*n;
	ans%=mod;
	if(ans<0)ans+=mod;
	cout << ans << endl;
}
 

Measured memory_bytes: 78336
#include "bits/stdc++.h"

using namespace std;
int main(void){
    int n;
    while (cin >> n && n) {
        int count = n != 1 ? 0 : 1;
        for (int i = n + 1; i <= 2 * n; ++i) {
            if (i % 2 == 0) continue;
            int e = sqrt(i);
            bool p = true;
            for (int j = 2; j <= e; ++j) {
                if (i % j == 0) {
                    p = false;
                    break;
                }
            }
            if (p) ++count;
        }
        cout << count << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 3;

struct bit {
	vector<ll> v;
	bit(int n) : v(n + 1) {}
	ll sum(int i) {
		ll res = 0;
		for (; i > 0; i -= i & -i) res += v[i];
		return res;
	}
	void add(int i, ll x) {
		for (i++; i < v.size(); i += i & -i) v[i] += x;
	}
};

int main() {
	int n; cin >> n;
	vector<int> p(n), l(n);
	for (int i = 0; i < n; i++)
		cin >> p[i];
	for (int i = 0; i < n; i++)
		cin >> l[i];
	vector<ll> sum(n + 1);
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + p[i - 1];
	vector<ll_i> a(n + 1);
	for (int i = 0; i <= n; i++)
		a[i] = ll_i(sum[i], i);
	sort(a.begin(), a.end());
	for (int i = 0; i + 1 <= n; i++)
		if (a[i + 1].first - a[i].first < l[i]) {
			cout << -1 << endl;
			return 0;
		}
	bit b(n + 1);
	ll ans = 0;
	for (int i = n; i >= 0; i--) {
		ans += b.sum(a[i].second);
		b.add(a[i].second, 1);
	}
	cout << ans << endl;
}

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

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

Measured memory_bytes: 256
N=int(input())
S=[1 if c=='o' else 0 for c in input()]
S+=S[:2]
from itertools import product
f=0
for a,b in product(range(2),repeat=2):
    r=[a,b]+[0]*N
    for i in range(N):
        r[i+2]=r[i] if r[i+1]^S[i+1] else r[i]^1
    if r[:2]==r[N:]:
        f=1
        break
print(''.join(['S' if x==0 else 'W' for x in r[:N]]) if f else -1)

Measured memory_bytes: 6904
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  int H,W,i,j,count=0;
  cin >> H >> W;
  char S[H+2][W+2];
  rep(i,H){
    rep(j,W){
      S[i][j] = '.';
    }
  }
  for(i=1;i<H+1;i++){
    for(j=1;j<W+1;j++){
      cin >> S[i][j];
    }
  }
  for(i=1;i<H+1;i++){
    for(j=1;j<W+1;j++){
      if(S[i][j]=='.'){
        if(S[i-1][j-1]=='#'){
          count+=1;
        }
        if(S[i-1][j]=='#'){
          count+=1;
        }
        if(S[i-1][j+1]=='#'){
          count+=1;
        }
        if(S[i][j+1]=='#'){
          count+=1;
        }
        if(S[i+1][j+1]=='#'){
          count+=1;
        }
        if(S[i+1][j]=='#'){
          count+=1;
        }
        if(S[i+1][j-1]=='#'){
          count+=1;
        }
        if(S[i][j-1]=='#'){
          count+=1;
        }
        cout << count;
        count=0;
      }else{
        cout << S[i][j];
      }
    }
    cout << '\n';
  }


    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n;
ll dp[3], a, b, c, d;
char o;
int main(){
	scanf("%d%lld", &n, dp);
	dp[1] = dp[2] = -1e15;
	rep(i,n-1){
		scanf(" %c %lld", &o, &a);
		b = dp[0]; c = dp[1]; d = dp[2];
		if(o == '+'){
			dp[0] = max({b, c, d}) + a;
			dp[1] = max(c, d) - a;
			dp[2] += a;
		}else{
			dp[0] = max({b, c, d}) - a;
			dp[1] = max(max(c, d) + a, b - a);
			dp[2] = max(c, d) + a;
		}
	}
	printf("%lld\n", max({dp[0], dp[1], dp[2]}));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char Field[14][14];
int move_x[12] = {-3, -2, -1, 1, 2, 3,  0,  0,  0, 0, 0, 0};
int move_y[12] = { 0,  0,  0, 0, 0, 0, -3, -2, -1, 1, 2, 3};

void DFS(int y, int x)
{
	Field[y][x] = '0';
	int nx, ny;
	for(int i = 0; i < 12; ++i)
	{
		nx = x + move_x[i];
		ny = y + move_y[i];
		if(Field[ny][nx] == '1')
		{
			DFS(ny, nx);
		}
	}
}

void solve()
{
	int N;
	cin >> N;
	int count = 1;
	while(N--)
	{
		for(int i = 0; i < 14; ++i)
		{
			for(int j = 0; j < 14; ++j)
			{
				Field[i][j] = '0';
			}
		}
		for(int i = 3; i < 11; ++i)
		{
			for(int j = 3; j < 11; ++j)
			{
				cin >> Field[i][j];
			}
		}
		int x, y;
		cin >> x >> y;
		if(Field[y + 2][x + 2] == '1')
		{
			DFS(y + 2, x + 2);
		}
		cout << "Data " << count << ":" << endl;
		++count;
		for(int i = 3; i < 11; ++i)
		{
			for(int j = 3; j < 11; ++j)
			{
				cout << Field[i][j];
			}
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int M = 30;
long long get(int vk[], int idx, vector<int>& a, vector<int>& b) {
  long long res = 0;
  for (int u = 0; u < (int) a.size(); u++) {
    bool flag = true;
    for (int i = idx; i < M; i++) {
      if (!vk[i] && (a[u] & (1 << i))) flag = false;
    }
    if (flag) res += b[u];
  }
  return res;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  int vk[M];
  for (int i = 0; i < M; i++) {
    vk[i] = (1 & (k >> i));
  }
  vector<int> a(n), b(n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (!vk[j] && (a[i] & (1 << j))) flag = false;
    }
    if (flag) ans += b[i];
  }
  for (int i = 0; i < M; i++) {
    if (vk[i]) {
      vk[i] = 0;
      ans = max(ans, get(vk, i, a, b));
      vk[i] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int const maxn=1e5+5;
struct xx
{
    int x,y,t;
}s[maxn];
int cmp(xx a,xx b)
{
    return a.t<b.t;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    scanf("%d%d%d",&s[i].t,&s[i].x,&s[i].y);
    sort(s,s+n,cmp);
    int judge=1,sx=0,sy=0;
    for(int i=0;i<n;i++)
    {
        int temp=abs(s[i].x-sx)+abs(s[i].y-sy);
        sx=s[i].x;
        sy=s[i].y;
        int t;
        if(i==0) t=s[i].t;
        else t=s[i].t-s[i-1].t;
        if(t<temp||(t-temp)%2!=0)
        {
            judge=0;
            break;
        }
    }
    if(judge) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int h, w;
string s[410];

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

void dfs(int y, int x, ll& black, ll& white) {
    visited[y][x] = true;
    if (s[y][x] == '#') black++;
    if (s[y][x] == '.') white++;
    rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
        if (visited[ny][nx]) continue;
        if (s[y][x] != s[ny][nx]) dfs(ny, nx, black, white);
    }
}

int main() {
    cin >> h >> w;
    rep(i, h) cin >> s[i];

    ll ans = 0;
    rep(y, h) rep(x, w) {
        if (visited[y][x]) continue;
        ll black = 0, white = 0;
        dfs(y, x, black, white);
        // cout << black << " " << white << endl;
        ans += black * white;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20608
#include<iostream>
#include<cstdio>
using namespace std;
//int cake(double yen,double cake,double possible){
//	double x;
  //  if((yen-cake)>possible){
    //	x=yen-cake;
	//}
	//double y;
	//y=yen-(x/possible*possible);
	//return y;
//}

int main(){
	int X,A,B;
    scanf("%d%d%d",&X,&A,&B);
    int result;
    result=(X-A)-(X-A)/B*B;
    printf("%d",result);
    return 0;
}


Measured memory_bytes: 256
from math import gcd

K = int(input())

a = 0
for ai in range(1, K + 1):
  for bi in range(1, K + 1):
    gcd_ab = gcd(ai, bi)
    for ci in range(1, K + 1):
      a += gcd(gcd_ab, ci)

print(a)

Measured memory_bytes: 9168
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
#import numpy as np

n =int(input())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
p=q=r=0
modnum = 1000000007
answer=1
for i in range(n):
    s=0
    if p == a[i]:
        s += 1
        p += 1
    if q == a[i]:
        s += 1
        if s==1:
            q += 1
    if r == a[i]:
        s += 1
        if s == 1:
            r += 1
#    print(p,q,r,s,a[i])
    answer = (answer * s) % modnum

print(answer)

Measured memory_bytes: 53044
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=101,maxw=1e5+1;
const ll INF=4e18;
ll w[maxn],v[maxn];
ll dp[maxn][maxw];
// dp[i][j] : denotes the maximum value that can be got
// by considering the first i elements of total weight j.
void solve()
{
	ll N,W;
	cin>>N>>W;
	for(ll i=1;i<=N;i++)
	{
		cin>>w[i]>>v[i];
	}
	
	for(ll i=0;i<=N;i++)
	{
		for(ll j=0;j<=W;j++)
		{
			// Base Case
			if(i==0||j==0) dp[i][j]=0;
			// When no element is picked, the value got is 0.
			
			else
			{
				if(j-w[i]>=0)
				{
					dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
				}
				else dp[i][j]=dp[i-1][j];
				// Either ith element can be picked or not picked
				// Take the best when both are done.
			}
			
		}
	}
	/*for(ll i=0;i<=N;i++)
	{
		for(ll j=0;j<=W;j++)
		{
			cout<<dp[i][j]<<" ";	Printing the dp values is a good
									way to debug
		}
		cout<<"\n";
	}*/
	ll m=-1;
	for(ll j=1;j<=W;j++)
	{
		m=max(dp[N][j],m);
	}
	cout<<m<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



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

int main(){
    int x, n, temp;
    int found[103] = {0};  // 0 means -1.  So +1 in everything.
    scanf("%d %d", &x, &n);
    for(int i = 0; i<n; i++){
        scanf("%d",&temp);
        found[temp+1] = 1;
    }
    int best_number = int(1e4);
    int best_difference = int(1e4);
    for(int i = -1; i <=101 ; i++){
        if (found[i+1] == 0) {
            if ( abs(i -x) < best_difference){
                best_difference = abs(i -x);
                best_number = i;
            }
        }
    }
    printf("%d\n", best_number);

    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b;
    k=(a+b)/2;
    if((abs(a-k))==(abs(b-k)))
    {
        cout<<k;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, q;

struct era{
	string name;
	int by, y;
	era(string _name, int _by, int _y) : name(_name), by(_by), y(_y){}
};

vector<era> v;

int main(){
	while (cin >> n >> q&&n+q){
		v.clear();
		REP(i, n){
			string s;
			int by, y;
			cin >> s >> by >> y;
			v.push_back(era(s, by, y));
		}
		REP(i, q){
			int y;
			bool f = 1;
			cin >> y;
			REP(j, v.size()){
				if (v[j].y - y <= v[j].by - 1 && v[j].y - y >= 0){
					cout << v[j].name << " " << v[j].by - (v[j].y - y) << endl;
					break;
				}
				if (j == v.size() - 1)cout << "Unknown" << endl;
			}
		}
	}
}

Measured memory_bytes: 1284
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner x = new Scanner(System.in);
		int h = x.nextInt();
		int w = x.nextInt();
		StringBuilder sb1 = new StringBuilder();
		while (h != 0 || w != 0){
			for (int i = 0 ; i < w ; i++ ){
				sb1.append("#");
			}
			int k = 0;
			sb1.append("\n");
			while (k < h-2){
			k++;
			sb1.append("#");
				for (int n = 0 ; n < w-2 ; n++){
				sb1.append(".");
				}
			sb1.append("#");
			sb1.append("\n");
			}

			for (int r = 0 ; r < w ; r++ ){
				sb1.append("#");
			}
			sb1.append("\n");
			sb1.append("\n");
			h = x.nextInt();
			w = x.nextInt();
		}
		System.out.print(sb1);
	}

}

Measured memory_bytes: 18616
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_string();

    println!("{}", n.chars().filter(|x| *x == '2').count());
}


Measured memory_bytes: 4352