akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    int H,W;
    cin >> H >> W;
    char a[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    
    vector<int> h(0);
    vector<int> w(0);
    for(int i = 0; i < H; i++){
        bool l = false;
        for(int j = 0; j < W; j++){
            if(a[i][j] == '#'){
                l = true;
            }
        }
        if(l)h.push_back(i);
    }
    for(int j = 0; j < W; j++){
        bool l = false;
        for(int i = 0; i < H; i++){
            if(a[i][j] == '#'){
                l = true;
            }
        }
        if(l)w.push_back(j);
    }
    for(int x : h){
        for(int y : w){
            cout << a[x][y];
        }
        cout << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char s[H+2][W+2];
  fill(s[0],s[H+2],'#');
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> s[i][j];
    }
  }

  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout << s[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

int main(){
    int n;
    cin >> n;

    double a = n / 1.08;
    int x = int(a);

    if(int(x*1.08) == n){
        cout << x << endl;
    }else{
        x += 1;
        if(int(x*1.08) == n){
            cout << x << endl;
        }else{
            cout << ":(" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

ll n,x;

int main() {
  cin >> n >> x;
  vector<ll> a(n,0);

  rep(i,n) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());


  int cnt = 0, ans = 0;
  while (x > 0 && cnt < n) {
    if (a[cnt] <= x) {
      if (cnt == n-1) {
        if (a[cnt] == x) {
          ans++;
        }
      } else {
        ans++;
        x -= a[cnt];
      }
    }
    cnt++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from random import sample
n=int(input())
if n==3:
    ans=[2,5,63]
else:
    L=[]
    for i in range(6,30001):
        if i%2==0 or i%3==0:
            L.append(i)
    while True:
        ans=[2,3,4]
        ans+=sample(L,n-3)
        if not sum(ans)%6:
            break
print(*ans)

Measured memory_bytes: 5940
#include<stdio.h>
#include<string.h>

int main(){
  int h,w;
  char s[101],c[300][300];
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++){
    scanf("%s",s);
    printf("%s\n",s);
    printf("%s\n",s);
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

set<int> st;
int main(){
    int n,d;
    cin>>n;
    rep(i,n){
        cin>>d;
        st.insert(d);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
# 2019/09/06

from bisect import bisect_left

n=int(input())
*a,mxv=sorted(list(map(int,input().split())))

mid=mxv//2

r=bisect_left(a,mid) 
if r>=n-1:
    r=0
l=r-1 if r else 0

ans=[mxv]

if abs(mxv/2-a[r])>abs(mxv/2-a[l]):
    ans.append(a[l])
else:
    ans.append(a[r])
print(*ans)

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

int main(){
    int a,b;	cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
	cout << "Possible" << endl;
    }else{
	cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    for (int i = 1; i <= 3; ++i) {
        if (A*B*i%2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	s := sum(a) % mod
	ans := 0
	for i := 0; i < n; i++ {
		x := s - a[i]
		if x < 0 {
			x += mod
		}
		ans += x * a[i] % mod
		ans %= mod
	}
	fmt.Println(ans * modinv(2, mod) % mod)
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


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

using namespace std;

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

int main() {
	int n, cnt[6] = {};
	cin >> n;
	REP(i, n) {
		double h;
		scanf("%lf", &h);
		h = (h - 165.0) / 5.0;
		if (h < 0.0) cnt[0]++;
		else {
			if ((int)h >= 4) cnt[5]++;
			else cnt[(int)h + 1]++;
		}
	}
	
	REP(i, 6) {
		printf("%d:", i + 1);
		REP(j, cnt[i]) printf("*");
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
n,k = list(map(int,input().split()))
x = list(map(int,input().split()))

res = 10 ** 10
l = 0
r = k-1
while r <= n-1:
    res = min(res,min(abs(x[l]),abs(x[r]))+(x[r]-x[l]))
    l+=1
    r+=1
print(res)


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

int keta(int x){
    int r=0,  k=0;
    while(x!=0){
        r=x%10; x/=10; k+=r;
    }
    return k;
}

int main(){
	int n; cin>>n;
	int ans=1e6+1;
	for(int i=1; i<n; i++){
		int a=i, b=n-i;
		int t=keta(a)+keta(b);
		ans=min(ans,t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll count = 0;
    vector<p> v;
    if (n % 2 == 0)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (i + 1 + j + 1 == n + 1)
                    continue;
                v.push_back(make_pair(i + 1, j + 1));
                count++;
            }
        }
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (i + 1 + j + 1 == n)
                    continue;
                v.push_back(make_pair(i + 1, j + 1));
                count++;
            }
        }
    }
    cout << count << "\n";
    for (int i = 0; i < v.size(); i++)
        cout << v[i].first << " " << v[i].second << "\n";
}


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

int main(){
    int n, tmp;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        mp[tmp]++;
    }

    int even_cnt = 0, ans = mp.size();
    for(auto x : mp){
        if(x.second % 2);
        else even_cnt++;
    }

    cout << ans - even_cnt % 2 << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


int main(){
    string s;
    cin>>s;
    vi c(26);
    rep(i,s.size()){
        c[s[i]-'a']++;
    }
    bool ok=true;
    rep(i,26){
        if(c[i]>1)ok=false;
    }
    if(ok)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<math.h>

typedef struct{
  double x, y;
}Point;

void koch(int n, Point a, Point b){
  if(n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2048
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;




char c;

int main(int argc, const char * argv[]) {
//    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> c;
    if (c == 'A') cout << "T\n";
    else if (c == 'T') cout << "A\n";
    else if (c == 'C') cout << "G\n";
    else cout << "C\n";
}



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

int main(){
    int R; cin >> R;
    if(R < 1200) {
        cout << "ABC" << endl;
    } else if(R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long


signed main(){
    int A1,A2,A3;
    cin >> A1 >> A2 >> A3;
    
    if(A1+A2+A3>=22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <string.h>
#include <unordered_map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;


void solve(const string& s)
{
    if(s.size() < 2){
        cout << "No" << endl;
        return;
    }
    int n = s.size();
    int c = -1, f = -1;
    for(int i = 0; i < n; ++ i){
        if(s[i] == 'C'){
            if(c == -1) c = i;
        }else if(s[i] == 'F'){
            if(c > -1){
                f = i;
            }
        }
    }
    if(c == -1 || f == -1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

int main()
{
    string s;
    while(cin >> s){
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1,	 -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e4 + 211;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, ans, x;

main () {				
	cin >> n;
	forn (i, 1, n) {
		cin >> x;
		if (x == ans + 1)
			++ans;
	}

	if (!ans)
		cout << -1;
	else
		cout << n - ans << endl;

}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    a = LIST()
    a5 = 0
    a7 = 0
    for A in a:
        if A == 5:
            a5 +=1
        elif A == 7:
            a7 +=1
    if a5 ==2 and a7 ==1:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
"use strict";

function main(input){
  const args = input.trim().split(' ').map(_=>parseInt(_,10));
  const n = args[0];
  const a = args[1];
  const b = args[2];
  
  let cnt = 0;
  for(let i=1; i<=n; i++){
    const c = i.toString().split('').map(_=>parseInt(_,10)).reduce((acc,cur)=>acc+cur);
    if(a <= c && c <= b) cnt+=i;
  }
  
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 10972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;

void solve() {
    int n, m;
    cin >> n >> m;
    if (n % 2 == 1) {
        rep(i, m) {
            cout << i + 1 << " " << n - i << endl;
        }
    } else {
        int l = 1, r = n;
        rep(i, m) {
            if (r - l > n / 2) {
                cout << l << " " << r << endl;
            } else {
                cout << l << " " << r - 1 << endl;
            }
            l++; r--;
        }
    }
    return;
}

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


Measured memory_bytes: 3604
program airplane
  implicit none
  integer :: p,q,r,a,b,ans

  read *, p,q,r
  if (p<q) then
    a = p
    b = q
  else
    a = q
    b = p
  end if
  if (r > b) then
    ans = a + b
  else
    ans = a + r
  end if
  print '(i0)', ans
end program airplane


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		int x;
		int y;
		int z;
		Scanner scan = new Scanner(System.in);
		String num = scan.nextLine();
		String[] numbers = num.split(" ");
		x = Integer.parseInt(numbers[0]);
		y = Integer.parseInt(numbers[1]);
		z = Integer.parseInt(numbers[2]);

System.out.println(z+" "+x+" "+y);

	}
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
double xs[51], ys[51];
double zs[51], ws[51];

bool f(double xc, double yc, double r){
    for(int i=0;i<N;++i){
        double dx = zs[i] - xc, dy = ws[i] - yc;

        if(std::sqrt(dx * dx + dy * dy) > r){
            return false;
        }
    }

    return true;
}

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

  std::cin >> N;

  for(int i=0;i<N;++i){
      std::cin >> xs[i] >> ys[i];
  }

  double res = 1e300;

  for(int i=0;i<N;++i){
      for(int j=0;j<N;++j){
          zs[j] = xs[j] - xs[i];
          ws[j] = ys[j] - ys[i];
      }

      for(int j=0;j<N;++j){
          for(int k=0;k<N;++k){
              if(zs[j] * ws[k] - zs[k] * ws[j] == 0){
                  double xc = zs[j] * 0.5, yc = ws[j] * 0.5, r = std::sqrt(xc * xc + yc * yc);
                  if(f(xc, yc, r)){
                      res = std::min(res, r);
                  }
              }else{
                  double alpha = zs[j] * zs[j] + ws[j] * ws[j],
                      beta = zs[k] * zs[k] + ws[k] * ws[k],
                      gamma = 4 * (zs[j] * ws[k] - zs[k] * ws[j]);

                  double xc = (alpha * 2 * ws[k] - beta * 2 * ws[j]) / gamma,
                      yc = (2. * zs[j] * beta - 2. * zs[k] * alpha) / gamma,
                      r = std::sqrt(xc * xc + yc * yc);

                  if(f(xc, yc, r)){
                      res = std::min(res, r);
                  }
              }
          }
      }
  }

  printf("%.10f\n", res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
/*
bool prime(ll n){if(n==1)return false;for(ll i=2;i*i<=n;i++)if(n%i==0){return false;}return true;}
void prime_fact(int n){for(int i=2;i*i<=n;i++){int count=0;if(n%i==0){while(n%i==0)n/=i,count++;cout<<i<<"^"<<count<<" ";}}if(n>1)cout<<n<<"^1";}
ll power(ll base ,ll pow){ll res=1;while(pow>0){if(pow&1)res*=base,pow-=1;else base*=base,pow/=2;}return res;}
void prime_fact_seieve(int n){for(int i=2;i<=size;i++){if(A[i]==0)for(ll j=i;j<=size;j+=i)if(A[i]==0)A[j]=i;}while(n>2){cout<<A[n]<<"*";n/=A[n];}}
template <class X> X gcd(X a , X b) { return b==0?a: gcd( b, a%b); }
template <class X> X lcm(X a , X b) { return a/gcd(a,b) * b ; }
ll Ab[N][N],I[N][N];  // identity matrix and a matrix to store result
void multiply(ll I[][N],ll A[][N],int dim)
{   int res[dim+1][dim+1];
    for(int i=0;i<dim;i++)
    {  for(int j=0;j<dim;j++)
        {
           res[i][j]=0;
           for(int k=0;k<dim;k++)
           {  res[i][j]+=((I[i][k]%mod)*(A[k][j])%mod)%mod;}}}

        for(int i=0;i<dim;i++)
            for(int j=0;j<dim;j++)
                I[i][j]=res[i][j];}
void powerMat(ll A[][N],int dim,int n)
{   for(int i=0;i<dim;i++)
    for(int j=0;j<dim;j++)
    {if(i==j) I[i][j]=1;
     else     I[i][j]=0;}
     while(n>0)
     {
         if(n%2)
         multiply(I,A,dim),n--;
         else
         multiply(A,A,dim),n/=2;
     }
     for(int i=0;i<dim;i++)
         for(int j=0;j<dim;j++)
             A[i][j]=I[i][j];
}
void printMat(ll A[][N],int dim)
{
    for(int i=0;i<dim;i++)
    {for(int j=0;j<dim;j++)
        {
            cout<<A[i][j]<<" ";
        }cout<<"\n";}
}
// REMEMBER PREFIX SUM SUFFIX SUM OR GCD VERY INTERESTING QUESTIONS
ll power(ll base ,ll pow,ll mo){ll res=1;while(pow>0){if(pow&1)res=(res%mo*base%mo)%mo,pow-=1;else base=(base%mo*base%mo)%mo,pow/=2;}return res;}*/
bool Binary(vector<int> arr,int n,int ele,int b)
{  int l=0,r=n-1,m;
   while(l<=r)
   {
       m=l+(r-l)/2;
       if(arr[m]==ele)
       {arr[m]=b;return true;}
       else if(arr[m]>ele)
           r=m-1;
       else
           l=r+1;
   }
    return false;

}

int main() {
    fast;
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;



}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0 ; i < n;++i)
#define pb push_back
using namespace std;
int n;
int a[110][110];
vector<int> G[11000];
int sumi[100020]={0};
int jou[11000];
int main(void){

cin>>n;
for(int i=0;i<2*n*n-2*n;i++){
int u,v;
cin>>u>>v;
G[u].pb(v);
G[v].pb(u);
}
vector<int> ka,hen;
for(int i=0;i<n*n;i++){
	if(G[i].size()==2)ka.pb(i);
	if(G[i].size()==3) hen.pb(i); 
	jou[i]=G[i].size();
}

a[1][1]=ka[0];
sumi[a[1][1]]=1;

//cout<<a[1][1]<<endl;
for(int i=2;i<=n-1;i++){
	int y;
	for(int j=0;j<G[a[1][i-1]].size();j++){
		if(G[G[a[1][i-1]][j]].size()==3  && sumi[G[a[1][i-1]][j]]==0) y=G[a[1][i-1]][j];
	}
	a[1][i]=y;
	sumi[y]=1;

//	cout<<y<<endl;
}
{
	int y;
	for(int j=0;j<G[a[1][n-1]].size();j++){
		if(G[G[a[1][n-1]][j]].size()==2 && sumi[G[a[1][n-1]][j]]==0) y=G[a[1][n-1]][j];
	}
	a[1][n]=y;		
	sumi[y]=1;

//	cout<<y<<endl;
}
for(int i=2;i<n;i++){
	for(int j=0;j<G[a[i-1][1]].size();j++){
		if(G[G[a[i-1][1]][j]].size()==3 && sumi[G[a[i-1][1]][j]]==0){
			a[i][1]=G[a[i-1][1]][j];
			sumi[a[i][1]]=1;
		}
	}	

	for(int k=2;k<=n;k++){
		for(int j=0;j<G[a[i-1][k]].size();j++)for(int l=0;l<G[a[i][k-1]].size();l++){
			if(G[a[i-1][k]][j]==G[a[i][k-1]][l] && sumi[G[a[i][k-1]][l]]==0){
				a[i][k]=G[a[i-1][k]][j];
				sumi[a[i][k]]=1;
			}
		}
	}

}

for(int j=0;j<G[a[n-1][1]].size();j++){
	if(G[G[a[n-1][1]][j]].size()==2 && sumi[G[a[n-1][1]][j]]==0){
		a[n][1]=G[a[n-1][1]][j];
		sumi[G[a[n-1][1]][j]]=1;
	}
}

for(int k=2;k<=n;k++){
		for(int j=0;j<G[a[n-1][k]].size();j++)for(int l=0;l<G[a[n][k-1]].size();l++){
			if(G[a[n-1][k]][j]==G[a[n][k-1]][l] && sumi[G[a[n][k-1]][l]]==0){
				a[n][k]=G[a[n-1][k]][j];
				sumi[a[n][k]]=1;
			}
		}
	}

for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
	return 0;


}


Measured memory_bytes: 3868
#include <iostream>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int,int> mp;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        mp[A]++;
    }

    int d = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        d += itr->second - 1;
    }

    cout << N - ((d+1)/2) * 2 << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const int n_max = 1e5+10;
const ll MOD = 1e9+7;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> bt(62,0);
    rep(i,n){
        rep(j,62){
            if((a[i] >> j) & 1)bt[j]++;
        }
    }
    // print(bt);
    ll res = 0;
    rep(i,62){
        ll base = 1LL << i;
        base %= MOD;
        ll num = bt[i] * (n-bt[i]) % MOD;
        res = (res + (base * num % MOD)) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 2688
a,b,c,d = [int(x) for x in input()]
op = [[i,j,k] for i in ['+','-'] for j in ['+','-'] for k in ['+','-']]

for x,y,z in op:
    f = "%d%s%d%s%d%s%d" % (a,x,b,y,c,z,d)
    if eval(f) == 7:
        print(f+'=7')
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	static vector<int> v(100005);
	int a;
	for(int i=0;i<N;i++){
		cin>>a;
		v[a+1]++;
		v[a]++;
      	if(a!=0){
			v[a-1]++;
        }
	}
	sort(v.begin(),v.end(),greater<int>());
	cout<<v[0]<<endl;
}

Measured memory_bytes: 640
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    map<string, ll> m;
    rep(i, n)
    {
        ++m[s[i]];
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 5164
#include<iostream>
using namespace std;
main()
{
	string str1;
	cin>>str1;
	int len=str1.length();
	if(len==6)
	{ 
		char c3= str1.at(2);
		char c4= str1.at(3);
		char c5= str1.at(4);
		char c6= str1.at(5);
		if(c3==c4 && c5==c6)
		{
		     cout<<"Yes"<<"\n";
		 }
		else
		{
			cout<<"No"<<"\n";
		}
	} 
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve()
{
    //If you cannot approach a problem
    //directly in the way it is proposed then try to think from backwards
    int n;
    cin>>n;
    ll arr[n];
    F(int, i, 0, n - 1){
        cin>>arr[i];
    }
    ll ans = 0LL;
    F(int, i, 0, n - 1){
        F(int, j, i + 1, n - 1){
            F(int, k, j + 1, n - 1){
                if((arr[i] == arr[j]) || (arr[i] == arr[k]) || (arr[j] == arr[k]))
                    continue;
                if(arr[i] + arr[j] <= arr[k])
                    continue;
                if(arr[i] + arr[k] <= arr[j])
                    continue;
                if(arr[k] + arr[j] <= arr[i])
                    continue;
                ans ++;
            }
        }
    }
    cout<<ans<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 3656
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nmx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Min(a.TakeWhile(x => x <= nmx[2]).Count(), a.SkipWhile(x => x <= nmx[2]).Count()));
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> S;
	std::cin >> T;
	T.erase(T.size()-1);
	if(S==T)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
int main()
{
	int N;
    scanf("%d",&N);
    N=N*(N+1)/2;
    if(N==1)
    {
		printf("1");
    }
    else
    {
		printf("%d",N);
    }
    system("pause");
    return 0;
}


Measured memory_bytes: 376
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int k = sc.nextInt();
        String s = sc.next();
        if (s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}


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

using namespace std;

int main(){
	string S,T;
	cin>>S>>T;
	if(S.length()>T.length()){
		swap(S,T);
	}
	vector<vector<short>>memo(S.length() + 1, vector<short>(26));
	for(int i = 0; i < S.length(); i++){
		memo[i+1]=memo[i];
		memo[i+1][S[i]-'a']++;
	}
	vector<vector<short>>memo2(T.length() + 1, vector<short>(26));
	for(int i = 0; i < T.length(); i++){
		memo2[i+1]=memo2[i];
		memo2[i+1][T[i]-'a']++;
	}
	{
		bool f=false;
		for(int i = 0; i< 26; i++){
			if(memo[S.length()][i]&&memo2[T.length()][i]){
				f=true;
				break;
			}
		}
		if(!f){
			cout<<0<<endl;
			return 0;
		}
	}

	vector<short>now(26);
	int ans=0;
	for(int len = S.length(); len >= 1; len--){
		set<vector<short>>SVI;
		for(int i = 0; i + len < memo.size(); i++){
			for(int k = 0; k < 26; k++){
				now[k] = memo[i+len][k] - memo[i][k];
			}
			SVI.insert(now);
		}
		for(int i = 0; i + len < memo2.size(); i++){
			for(int k = 0; k < 26; k++){
				now[k] = memo2[i+len][k] - memo2[i][k];
			}
			if(SVI.count(now)){
				cout<<len<<endl;
				return 0;
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3940
N = int(input())
S = input()

r_cnt = S.count("R")
g_cnt = S.count("G")
b_cnt = S.count("B")

ans = r_cnt * g_cnt * b_cnt

for i in range(N):
    for d in range(N):# 公差、文字の間隔
        j = i + d
        k = i + 2 * d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            ans -= 1
            
print(ans)


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

// hon 2,4,5,7,9
// pon 0,1,6,8
// bon 3
int main(){
  int x;
  cin >> x;
  switch(x%10){
    case 3:
      cout << "bon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon";
      break;
    default:
      cout << "hon";
      break;
  }
  return 0;
}

Measured memory_bytes: 3624
from itertools import accumulate
n,k = map(int,input().split())
mod = 998244353

alist = []
for i in range(k):
    l,r = map(int,input().split())
    alist.append((l,r))

dp = [0]*(n+1)
dp[1] = 1
dp[2] = -1

x = 0
for i in range(1,n):
    x = (x+dp[i])%mod
    for l,r in alist:
        if i+l > n:
            continue
        dp[i+l]= (dp[i+l]+x)%mod
        if i+r+1<=n:
            dp[i+r+1] = (dp[i+r+1]-x)%mod
x = (x+dp[n])%mod
print(x)




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

int main() {
    int n;
    cin >> n;

    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) {
        cin >> s[i] >> t[i];
    }

    string x;
    cin >> x;

    long long sum = 0;
    rep(i, n) sum += (long long)t[i];

    rep(i, n) {
        sum -= (long long)t[i];
        if (s[i] == x) break;
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
using namespace std;
const int N=2e5+5,M=6008;
int n,k,x,y,m;
string c;
int f[M][M];
int calc(int x1,int y1)
{
	int x2=x1+k-1,y2=y1+k-1;
	x1=max(1,x1),y1=max(1,y1);
	x2=min(x2,m),y2=min(y2,m);
	if(x2<x1||y2<y1)
		return 0;
	return f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;	
	m=2*k;
	memset(f,0,sizeof(f));
	rep(i,1,n)
	{
		cin>>x>>y>>c;
		if(c=="W")
			y+=k;
		x%=m,y%=m;
		x++,y++;
		f[x][y]++;
	}
	for(int i=1;i<=2*m;i++)
		for(int j=1;j<=2*m;j++)
			f[i][j]=f[i][j]+f[i][j-1]+f[i-1][j]-f[i-1][j-1];
	int res=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int cnt=calc(i,j);
			cnt+=calc(i-k,j-k)+calc(i-k,j+k)+calc(i+k,j-k)+calc(i+k,j+k);
			cnt+=calc(i-m,j)+calc(i+m,j)+calc(i,j-m)+calc(i,j+m);
			res=max(res,cnt);
		}
	}
	cout<<res<<endl;
	return 0;
	
}

Measured memory_bytes: 141440
import java.util.Scanner;
public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int days = scan.nextInt();
		int activites[][] = new int[days+1][4];
		for(int i=1;i<=days;i++) {
			activites[i][1] = scan.nextInt();
			activites[i][2] = scan.nextInt();
			activites[i][3] = scan.nextInt();
		}
		
		int points = Integer.MIN_VALUE;
		
		int[][] dp = new int[days+1][4];
		for(int i=1;i<=3;i++) {
			points = Math.max(points, happiness(activites,1,i,dp));
		}
				
		System.out.println(points);
	}
	
	public static int happiness(int[][] act,int day,int currentActvity, int[][] dp) {
		
		if(day >= act.length) {
			return 0;
		}
		
		if(dp[day][currentActvity] != 0) {
			return dp[day][currentActvity];
		}
		
		int points = Integer.MIN_VALUE;
				
		for(int i=1;i<=3;i++) {
			if(i != currentActvity) {
				points = Math.max(points, happiness(act, day+1, i,dp));
			}
		}
		
		dp[day][currentActvity] = points + act[day][currentActvity];
		return dp[day][currentActvity];
	}
}

Measured memory_bytes: 69176
#include<stdio.h>
#include<string.h>
int main(){
  int n,a,x[8],i,cnt=0,min=0,max=0;
  scanf("%d",&n);
  for(i=0; i<8; i++){
    x[i]=0;
  }
  for(i=0; i<n; i++){
    scanf("%d",&a);
    if(a<400){
      x[0]=1;
    }
    else if(a>=400 && a<800){
      x[1]=1;
    }
    else if(a>=800 && a<1200){
      x[2]=1;
    }
    else if(a>=1200 && a<1600){
      x[3]=1;
    }
    else if(a>=1600 && a<2000){
      x[4]=1;
    }
    else if(a>=2000 && a<2400){
      x[5]=1;
    }
    else if(a>=2400 && a<2800){
      x[6]=1;
    }
    else if(a>=2800 && a<3200){
      x[7]=1;
    }
    else{
      cnt++;
    }
  }
  for(i=0; i<8; i++){
    min=min+x[i];
  }
  max=min+cnt;
  if(min==0){
    min=1;
    max=cnt;
  }
  printf("%d %d\n",min,max);
  return 0;
}


Measured memory_bytes: 128
<?php
class Scanner { //http://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}
$sc = new Scanner();
$n = $sc->next();

out::println(str_replace(","," ",$n));

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

int main(){
	int dat;
	cin >> dat;
	for(int di = 0;di < dat;di++){
		int x,y,n,x1[100],y1[100],x2[100],y2[100];
		bool cx[16][16] = {},cy[16][16] = {};
		int dp[17][17] = {};
		cin >> x >> y >> n;
		for(int i = 0;i < n;i++) {
			cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
			if(x1[i] > x2[i]){
				int t = x2[i];
				x2[i] = x1[i];
				x1[i] = t;
			}
			if(y1[i] > y2[i]){
				int t = y2[i];
				y2[i] = y1[i];
				y1[i] = t;
			}
			if(x1[i] == x2[i]) cy[x1[i]][y1[i]] = true;
			else cx[x1[i]][y1[i]] = true;
		}
		dp[0][0] = 1;
		for(int i = 0;i <= x;i++){
			for(int j = 0;j <= y;j++){
				if(!cy[i][j]) dp[i][j + 1] += dp[i][j];
				if(!cx[i][j]) dp[i + 1][j] += dp[i][j];
			}
		}
		if(dp[x][y]) cout << dp[x][y] << endl;
		else cout << "Miserable Hokusai!" << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

int w, h, xs, ys, xg, yg, n;
int board[110][110];
bool used[110][110];

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

bool valid(int x, int y) {
    return 0 < x && x <= w && 0 < y && y <= h;
}

bool dfs(int x, int y) {
    if (x == xg && y == yg) return true;
    used[y][x] = true;
    for (int i=0; i<4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (valid(nx, ny) && ! used[ny][nx] && board[ny][nx] == board[y][x] && dfs(nx, ny)) {
            return true;
        }
    }
    return false;
}

int main() {
    while (cin >> w >> h, (w || h)) {
        cin >> xs >> ys >> xg >> yg >> n;
        int c, d, x, y;
        for (int i=0; i<n; ++i) {
            cin >> c >> d >> x >> y;
            for (int j=0; j<2; ++j) {
                for (int k=0; k<4; ++k) {
                    if (d == 0) {
                        board[y + j][x + k] = c;
                    } else {
                        board[y + k][x + j] = c;
                    }
                }
            }
        }
        memset(used, false, sizeof used);
        cout << (dfs(xs, ys) ? "OK" : "NG") << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;;
int main() {
	int N,X; cin>>N>>X;
	int x[100000];
	for(int i=0;i<N;i++){
		cin>>x[i];
		x[i] =abs(x[i]-X);
	}
	int res=x[0];
  	for(int i=1;i<N;i++)
      res =__gcd(res,x[i]);

	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
import scala.io.StdIn

object Main extends App {

  val r = StdIn.readLine().split(" ") match {
    case Array(a: String, "+", b: String) => a.toInt + b.toInt
    case Array(a: String, "-", b: String) => a.toInt - b.toInt
    case _ => throw new IllegalArgumentException
  }
  
  println(r)
  
}


Measured memory_bytes: 25416
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int k;
  cin >> k ;
  cout << k * k << endl;
  return 0;
}


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

/*
問題文
高橋君はあるプログラミングコンテストが行われているサイトに参加しています。
ここでは, コンテストに出場した時にこの順位に応じて「パフォーマンス」というものがつき、
それによってレーティング (整数とは限らない) が次のように変化します。

現在のレーティングを aとする。
 次のコンテストで, パフォーマンス bを取ったとする。
そのとき, レーティングは aと bの平均まで変化する。
 例えば, レーティングが 1の人が次のコンテストでパフォーマンス 1000を取ったら,
レーティングは 1と 1000の平均である 500.5になります。
高橋君は, 現在のレーティングが Rで, 次のコンテストでレーティングをちょうど Gにしたいと思っています。
 そのとき, 高橋君が取るべきパフォーマンスを求めなさい。

制約
0≤R
G≤4500
入力はすべて整数
*/
int main(){
  int r;
  int g;
  double x = 0.0;
  scanf("%d", &r);
  scanf("%d", &g);
  if(r < 0 || 4500 < g){
    return 1;
  }
  x = (2 * g) - r;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    int a,b;
    std::cin >> a >> b;
    if(a > b){
        rep(i, a) {
            std::cout << b;
            
        }
    }
    else{
        rep(i, b) {
            cout << a;
            
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;


void solve()
{
 int n;
 cin>>n;
 int val= 7%n;
 for(int i=1;i<=n;i++)
 {
     if(val==0)
     {
         cout<<i;
         return;
     }
     val=(val*10+7)%n;
 }
 cout<<-1;
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
string s;int k;
int main()
{
	cin>>s>>k;
	bool flag=1;
	for(int i=0;i<(int)s.size();i++) if(s[i]!=s[0]) flag=0;
	if(flag) return printf("%lld\n",1ll*s.size()*k/2),0;
	long long ans=0;
	if(s[0]==s[s.size()-1])
	{
		int l=0,r=s.size()-1;
		while(s[l+1]==s[l]) l++;
		while(s[r-1]==s[r]) r--;
		int lcnt=l+1,rcnt=s.size()-r;
		ans+=lcnt/2+rcnt/2+1ll*(lcnt+rcnt)/2*(k-1);
		string t="";
		for(int i=l+1;i<r;i++) t+=s[i];
		s=t;
	}
	int cnt=0;
	for(int i=0;i<(int)s.size();i++)
	{
		cnt++;
		if(i+1==(int)s.size()||s[i+1]!=s[i])
		{
			ans+=1ll*cnt/2*k;
			cnt=0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int N;
    cin>>N;
    vector <int>t(N);
    vector <int>x(N);
	vector <int>y(N);
	for(int i=0 ; i<N ; i++){
        cin>>t[i]>>x[i]>>y[i];
    }
	long x1=0;
	long y1=0;
	long disx=0;
	long disy=0;
	bool ts=true;
	int to=0;
	for(int i=0 ; i<N ; i++){
		disx=x[i]-x1;
		disy=y[i]-y1;
		if(disx<0)disx*=-1;
		if(disy<0)disy*=-1;
		//cout<<disx+disy<<endl;
		if((t[i]-to)<(disx+disy) || ((t[i]-to)%2)!=((disx+disy)%2)){
			ts=false;
			break;
		}
		x1=x[i];
		y1=y[i];
		to=t[i];
	}
	if(ts)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


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

using ll = int64_t;
using ull = uint64_t;
#define rep(i, n) for (ull i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, s, n) for (ull i = s, i##_len = (n); i < i##_len; ++i)

int main()
{
    ll n, a;
    cin >> n >> a;
    int x[50];
    int maxValue = 0;
    rep(i, n)
    {
        cin >> x[i];
        maxValue = max(x[i], maxValue);
    }
    ll ***pd = new ll **[n + 1];
    rep(i, n + 1) // 枚数
    {
        pd[i] = new ll *[n + 1];
        rep(k, n + 1) // 選ぶ枚数
        {
            pd[i][k] = new ll[(n + 1) * maxValue];
            rep(m, (n + 1) * maxValue) // 合計値
            {
                if (i == 0 && k == 0 && m == 0)
                {
                    pd[i][k][m] = 1;
                }
                else if (i >= 1 && m < x[i - 1])
                {
                    pd[i][k][m] = pd[i - 1][k][m];
                }
                else if (i >= 1 && k >= 1 && x[i - 1] <= m)
                {
                    pd[i][k][m] = pd[i - 1][k][m] + pd[i - 1][k - 1][m - x[i - 1]];
                }
                else
                {
                    pd[i][k][m] = 0;
                }
            }
        }
    }
    ull result = 0;
    rep2(i, 1, n + 1)
    {
        result += pd[n][i][a * i];
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 52096