akhauriyash/Code-Regression huggingface dataset:
import math
a,b,c=map(int,input().split())
s=(a*b*math.sin(math.radians(c)))/2
l=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))
l=l+a+b
h=2*s/a
print(s,l,h)


Measured memory_bytes: 5708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
map<long long,long long> f;
const long long mod=1e9+7;
long long DP(long long x)
{
	if(f[x]!=0) return  f[x]%mod;
	else return f[x]=(DP(x/2)+DP((x-1)/2)+DP((x-2)/2))%mod;
 } 
int main()
{
	long long n;
	cin>>n;
	f[0]=1;
	f[1]=2;
	cout<<DP(n);
	return 0;
 } 

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	MOD = 10**9 + 7
	n = int(rl())
	G = [[] for _ in range(n)]
	for _ in range(n-1):
		u, v = rli()
		u -= 1
		v -= 1
		G[u].append(v)
		G[v].append(u)


	wb = [[1,1] for _ in range(n+1)]
	wb[n] = [0, 0]
	seen = [0 for _ in range(n)]
	stack = []
	stack.append((0, n))
	while stack:
		node, prnt = stack.pop()
		w, b = wb[node]
		if not seen[node]:
			seen[node] = 1
			stack.append((node, prnt))
			for nbhr in G[node]:
				if nbhr == prnt: continue
				stack.append((nbhr, node))
		else:
			pw, pb = wb[prnt]
			pw *= (w + b)
			pb *= w 
			wb[prnt] = [pw % MOD, pb % MOD]

	ans = (wb[0][0] + wb[0][1]) % MOD
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 114524
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 24) cout << (a + b) - 24 << endl;
    else cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

public class Main{

static int mod=(int)1e9+7;
 public static void main(String[] $) {

   Scanner sc=new Scanner(System.in);
   int n=sc.nextInt();
   int m=sc.nextInt();
   ArrayList<ArrayList<Integer>> a=new ArrayList<>();
   for(int i=0;i<n;i++) {
     a.add(new ArrayList<>());
   }
   for(int i=0;i<m;i++) {
     int x=sc.nextInt()-1;
     int y=sc.nextInt()-1;
     a.get(y).add(x);
     a.get(x).add(y);
   }
   boolean vis[]=new boolean[n];
   int count=0;
   for(int i=0;i<n;i++) {
     if(vis[i]==false) {
       if(i!=0) {
         count++;
       }
       dfs(a,i,vis);
     }
   }
   System.out.println(count);
}
static int msb(int a){
   int k=(int)(Math.log(a)/Math.log(2));
   return k;
}
static void dfs(ArrayList<ArrayList<Integer>> aa,int src,boolean vis[]) {
  vis[src]=true;
  for(int i:aa.get(src)) {
    if(vis[i]==false) {
      dfs(aa,i,vis);
    }
  }
}

static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
}

}
class pair{
  int x,y;
  pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}

Measured memory_bytes: 76584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		if(s.length() % 2 == 1) {
			System.out.println("No");
		} else {
			String t = s.substring(0, s.length() / 2);
			String u = s.substring(s.length() / 2);
			if(t.equals(u)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	string n;
	cin >> n;
	if (n[0] == n[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX/2+2], R[MAX/2+2];

llong merge(int A[], int n, int left , int mid, int right ){
    int i,j,k;
    llong cnt = 0;
    int n1= mid - left;
    int n2 = right - mid;
    for(i=0; i<n1; i++) L[i]=A[left + i];
    for(i=0; i<n2; i++) R[i]=A[mid + i];
    L[n1]=R[n2]=SENTINEL;
    i=j=0;
    for(k=left; k<right; k++){
        if(L[i]<=R[j]) {
            A[k] = L[i++];
        } else {
            A[k]= R[j++];
            cnt += n1 -i;
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
    int mid;
    llong v1,v2,v3;
    if(left+1<right){
        mid=(left+right)/2;
        v1=mergeSort(A,n,left,mid);
        v2=mergeSort(A,n,mid,right);
        v3=merge(A,n,left,mid,right);
        return v1+v2+v3;
    } else return 0;
}

int main(){
    int A[MAX], n,i;
    
    cin >>n;
    for(i=0; i<n; i++){
        cin >> A[i];
    }
    
    llong ans = mergeSort(A,n,0,n);
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 4656
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)

using namespace std;

int main(){
  int n;
  cin >> n;
  long long result = 0;
  map<int, bool> check;
  rep(i, n){
    long long input;
    cin >> input;
    check[input] = !check[input];
    if (check[input]) {
      result += 1;
    }else{
      result -= 1;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct unifnd{
  VI ht,pr;
  in fnd(in a){
    in ta=a;
    while(a!=pr[a])a=pr[a];
    in tt=ta;
    while(ta!=a){
      tt=pr[ta];
      pr[ta]=a;
      ta=tt;
    }
    return a;
  }
  void uni(in a, in b){
    a=fnd(a);
    b=fnd(b);
    if(a==b)return;
    if(ht[b]<ht[a])swap(a,b);
    pr[a]=b;
    ht[b]+=(ht[a]==ht[b]);
  }
  void ini(in n){
    ht.resize(n);
    pr.resize(n);
    forn(i,n){
      ht[i]=0;
      pr[i]=i;
    }
  }
};
set<in> himb;
VI ap;
unifnd tfd;
VI dgl,dgr;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,h,a,b,c,d;
  cin>>n>>h;
  const in ofs=h+9;
  tfd.ini(ofs*2);
  dgl.resize(h+3);
  dgr.resize(h+3);
  in ta,tb;
  forn(z,n){
    cin>>a>>b>>c>>d;
    if(c==0){
      ta=a;
      ++dgl[a];
    }
    else{
      ta=ofs+c;
      ++dgr[c];
    }
    if(d==0){
      tb=ofs+b;
      --dgr[b];
    }
    else{
      tb=d;
      --dgl[d];
    }
    tfd.uni(ta,tb);
    ap.PB(ta);
    ap.PB(tb);
  }
  forv(i,dgl){
    if(dgl[i]<0){
      cout<<"NO"<<endl;
      return 0;
    }
    if(dgl[i]>0)
      himb.insert(tfd.fnd(i));
  }
  forv(i,dgr){
    if(dgr[i]>0){
      cout<<"NO"<<endl;
      return 0;
    }
    if(dgr[i]<0)
      himb.insert(tfd.fnd(ofs+i));
  }
  forv(i,ap){
    if(!himb.count(tfd.fnd(ap[i]))){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}


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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 2e5+50;
int n, k, a[N];

bool check(int m) {
    int cnt = 0;
    for (int i=0; i<n; ++i) {
        cnt += (a[i] - 1) / m;
    }
    return cnt <= k;
}

void solve() {
    scanf("%d%d", &n, &k);
    for (int i=0; i<n; ++i)
        scanf("%d", &a[i]);

    int l = 0, r = 1000000000;
    while (l < r-1) {
        int m = (l+r) >> 1;
        
        if (check(m)) {
            r = m;
        } else {
            l = m;
        }
    }
    printf("%d\n", r);
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 4484
#include<stdio.h>
int main(){
  int A1, A2, A3;
  scanf("%d %d %d",&A1, &A2, &A3 );
  int A4 = A1+A2+A3;
  if(A4 >= 22){
    printf("bust\n");
  }else{
    printf("win\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		
		int aa = input / 100;
		int bb = input % 100;
		
		boolean yymm = false;
		boolean mmyy = false;
		
		if(aa >= 1 && aa <= 12) {
			mmyy = true;
		}
		
		if(bb >= 1 && bb <= 12) {
			yymm = true;
		}
		
		if(yymm && mmyy) {
			System.out.println("AMBIGUOUS");
		}
		else if(yymm && !mmyy) {
			System.out.println("YYMM");
		}
		else if(!yymm && mmyy) {
			System.out.println("MMYY");
		}
		else {
			System.out.println("NA");
		}
	}

}


Measured memory_bytes: 21844
import sys
SA = list(input())
SB = list(input())
SC = list(input())
letter = "a"
for i in range(400):
    if letter == "a":
        if SA == []:
            print("A")
            sys.exit()
        letter = SA[0]
        SA = SA[1:]
    elif letter == "b":
        if SB == []:
            print("B")
            sys.exit()
        letter = SB[0]
        SB = SB[1:]
    else:
        if SC == []:
            print("C")
            sys.exit()
        letter = SC[0]
        SC = SC[1:]

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

int n;
int p[limit];

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>n;
  rep(i, n)cin>>p[i];
  
  int c=0;
  
  rep(i, n) {
    if(p[i]==i+1) {
      c++;
      i++;
    }
  }
  
  cout<<c<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    
    for (int h = 0; h < B; ++h) {
        for (int w = 0; w < A; ++w) {
            cout << '0';
        }
        for (int  w = A; w < W; ++w) {
            cout << '1';
        }
        cout <<'\n';
    }
    for (int h = B; h < H; ++h) {
        for (int w = 0; w < A; ++w) {
            cout << '1';
        }
        for (int w = A; w < W; ++w) {
            cout << '0';
        }
        cout <<'\n';
    }

    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class UnionFind {
public:
    vector<int> par, union_size;
    vector<set<int>> group; // group[i] := ???i?????????????±???????????´?????????§
    
    UnionFind(int n) : par(n), union_size(n, 1), group(n)
    {
        for (int i=0; i<n; i++) {
            par[i] = i;
            group[i].insert(i);
        }
    }
    
    // ??¨??????????±???????
    int find(int x)
    {
        return (par[x] == x ? x : par[x] = find(par[x]));
    }
    
    // x??¨y????±????????????????????????????
    void merge(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y) return;
        if (union_size[x] < union_size[y]) swap(x, y);

        union_size[x] += union_size[y];
        union_size[y] = union_size[x];

        par[y] = x;
        group[x].insert(group[y].begin(), group[y].end());
        group[y] = set<int>();
    }
    
    bool is_same(int x, int y) { return find(x) == find(y); }
};

int main()
{
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;

    UnionFind UF(N);
    rep(i, Q) {
        int C, X, Y;
        cin >> C >> X >> Y;

        if (C == 0) {
            UF.merge(X, Y);
        } else {
            cout << UF.is_same(X, Y) << endl;
        }
    }
}

Measured memory_bytes: 3880
MOD = 10 ** 9 + 7
S = input()
LS = len(S)
dp = [[0] * 13 for _ in range(LS+1)]
dp[0][0] = 1

for k in range(LS):
    #prev = [x for x in dp]
    #dp = [0] * 13
    s = S[k]
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[k+1][(i*10+a)%13] += dp[k][i]
    dp[k+1] = [x % MOD for x in dp[k+1]]
print(dp[LS][5])

Measured memory_bytes: 80348
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

double mp[111][111];
bool L[111];
bool B[111];
int n,t,l,b;

int main()
{
	while(cin >> n >> t >> l >> b,n|t|l|b)
	{
		REP(i,111)REP(j,111)mp[i][j] = 0;
		REP(i,111)L[i] = B[i] = false;
		mp[0][0] = 1;
		
		REP(i,l)
		{
			int tmp;cin >> tmp;L[tmp] = true;
		}
		REP(i,b)
		{
			int tmp;cin >> tmp;B[tmp] = true;
		}
		
		REP(i,t)
		{
			REP(j,n)
			{
				if(mp[i][j] > 0)
				{
					REP(k,6)
					{
						int tmp = j + k + 1;
						int turn = i+1;
						if(tmp > n)tmp = 2*n - tmp;
						if(L[tmp])turn++;
						if(B[tmp])tmp = 0;
						mp[turn][tmp] += mp[i][j] / 6;
					}
				}
			}
		}
		
		//SHOW2d(mp,t+1,n+1);
		
		
		double ans = 0;
		REP(i,t+1)
		{
			ans += mp[i][n];
		}
		
		cout << Decimal << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3360
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>

using namespace std;

int val[200007];
vector<int> c[200007];
bool vis[200007];

void bfs(int node, int parent)
{
    if(vis[node]) return;
    vis[node]=true;
    val[node]+=val[parent];
    for(int i=0; i<c[node].size(); i++)
    {
        bfs(c[node][i], node);
    }
    return;
}

int main()
{
    int N,Q;
    scanf("%d %d\n",&N,&Q);

    int a,b;
    for(int i=1; i<N; i++)
    {
        scanf("%d %d\n",&a,&b);
        c[a].push_back(b);
        c[b].push_back(a);
    }

    for(int i=1; i<=Q; i++)
    {
        scanf("%d %d\n",&a,&b);
        val[a]+=b;
    }

    bfs(1,0);

    for(int i=1; i<=N; i++)
    {
        printf("%d ",val[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	vi num(n);
	set<int> si;
	map<int,int> mpii;
	REP(i, n) {
		cin >> num[i];
		si.insert(num[i]);
		mpii[num[i]]++;
	}
	for (auto x : si)
		if (mpii[x] % 2 == 0)
			mpii[x] = 2;
		else
			mpii[x] = 1;
	int cnt = 0;
	bool sta = false;
	bool ni = false;;
	for (auto x : si)
		if (mpii[x] == 2) {
			cnt++;
			if (sta)
				ni = true;
			sta = true;
		}
		else {
			sta = false;
		}

	if (cnt % 2 == 1) {
		cout << si.size() - 1 << endl;
	}
	else {
		if (cnt == 2&&ni) {
			cout << si.size() - 1 << endl;
		}
		else {
			cout << si.size()<< endl;
		}

	}
}

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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define in_range(x,l,r) (lb(all(x),r+1)-lb(all(x),l))
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define fore(i,x) for (auto &i:x)
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=+3;

int n;

int main(){
	cin>>n;
	cout<<(n-2)*180<<endl;
	re 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int INF = 1001001001;

int main(){
    int n,x;cin >>n>>x;
    v l(n);
    rep(i,n)cin >> l[i];
    
    int d=0;
    int ans = 1;
    rep(i,n){
        d += l[i];
        if(d>x)break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    int v[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] - c[i] > 0)
        {
            sum += v[i] - c[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}
int h, w, k;
char c[6][6];

int count(int is, int js) {
    int res = 0;
    set<int> sh, sw;
    int tmp1 = is, tmp2 = js;

    int ii = 0;    
    do {
        if (is % 2 == 1)
            sh.insert(ii);
        is /= 2;
        ii++;
    } while(is != 0);

    ii = 0;
    do {
        if (js % 2 == 1)
            sw.insert(ii);
        js /= 2;
        ii++;
    }while (js != 0);


    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            auto iti = sh.find(i);
            if (iti != sh.end())
                continue;
            auto itj = sw.find(j);
            if (itj != sw.end())
                continue;

            if (c[i][j] == '#') {
                res++;
                //cout << i << " " << j << " ";
            }
        }
    }
    return res;
}

int main()
{
     cin >> h >> w >> k;
    rep(i,6) {
        rep(j,6) {
            c[i][j] = '.';
        }
    }
    rep(i,h) {
        rep(j,w) {
            cin >> c[i][j];
        }
    }
    int res;
    int ans = 0;
    rep(i,pow(2,h)) {
        rep(j,pow(2,w)) {
            res = count(i,j);
            if (res == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4088
#include<stdio.h>
int main(void){
	while(1){
		int n;
		int a[100]={};
		scanf("%d",&n);
		if(n==0)break;
		int i;
		for(i=0;i<n;i++){
			int s;
			int j;
			for(j=0;j<5;j++){
				scanf("%d",&s);
				a[i]+=s;
			}
			int g,h;
			for(g=0;g<n-1;g++){
				for(h=n-1;g<h;h--){
					if(a[h]>a[h-1]){
						int tmp;
						tmp=a[h];
						a[h]=a[h-1];
						a[h-1]=tmp;
					}
				}
			}
			
		
		}
		printf("%d %d\n",a[0],a[n-1]);
	}
	return 0;
}

Measured memory_bytes: 1028
#!/usr/bin/env python3
import sys


def factors(n):
    L = []
    for i in range(1, n+1):
        if i * i > n:
            break
        if n % i == 0:
            L.append(i)
            if n // i != i:
                L.append(n // i)
    return L


def solve(N: int, K: int, A: "List[int]"):
    facts = factors(sum(A))
    facts.sort(reverse=True)
    for f in facts:
        B = sorted([a % f for a in A])
        d_m = []
        d_p = []
        for b in B:
            diff_minus = b
            diff_plus = f - diff_minus
            d_m.append(diff_minus)
            d_p.append(diff_plus)
        s_m = 0
        s_p = sum(d_p)
        for i in range(N):
            if s_m == s_p:
                break
            if s_m > s_p:
                print('okashii')
                break
            s_m += d_m[i]
            s_p -= d_p[i]
        if s_m <= K:
            print(f)
            return
            
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


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

ll cnt[100005];

int main() {
	// your code goes here
	int n;
	memset(cnt,0,sizeof(cnt));
    cin >> n;
	int a[n+1];
	ll sum = 0;
	for(int i = 1;i <= n ; ++i){
		cin >> a[i];
		sum += a[i];
		++cnt[a[i]];
	}
	
	int q;
	cin >> q;
	while(q-- > 0){
		int idx, re;
		cin >> idx >> re;
		sum += cnt[idx] * re;
		sum -= cnt[idx]*idx;
		cnt[re] += cnt[idx];
		cnt[idx] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
#define pf printf
#define sf(a) scanf("%d",&a);
int main( )
{
	string s,t;
	cin>>s>>t;
	int x=0;
	int l=s.size( );
	for(int i=0;i<s.size( );i++){
		if(s[i]!=t[i])x++;
	}
	cout<<x<<endl;
}

Measured memory_bytes: 3920
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());

//        String str1 = scan.next();
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());
        String str1 = scan.next();

        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";


        StringBuilder sb = new StringBuilder();
        sb.append(str1);
        int int1 = Integer.parseInt(str1.substring(0,2));
        int int2 = Integer.parseInt(str1.substring(2,4));

        if(int1 < 13 && int2 < 13 && int2 > 0 && int1 > 0){
            ans = "AMBIGUOUS";
        }else if(int1>0 && int1<13){
            ans = "MMYY";
        }else if(int2 < 13 && int2 > 0){
            ans = "YYMM";
        }else {
            ans = "NA";
        }
            PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

int solve(int N, vi& a) {
    sort(ALL(a));

    vector<ll> ac(N+1);
    ac[0] = 0;
    rep(i,N) ac[i+1] = ac[i] + a[i];

    int cnt = 1;
    int bmin = N-1;
    for (int i=N-1; i>0; --i) {
        ll b = a[i];
        ll s = ac[i] - ac[0];
        if (s*2 >= b) { ++cnt; bmin = i-1; }
        else break;
    }
    return cnt;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 2432
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
char s[210];
long long k,ans,ans1;
int main()
{
    cin>>s>>k;
    int len=strlen(s);
    for(int i=0;i<len-1;i++)
    {
	int cnt=1;
	while(s[i]==s[i+1]&&i<len-1)
	    cnt++,i++;
//	cout<<cnt<<endl;
	ans+=cnt/2;
    }
    if(k==1)
    {
	printf("%lld",ans);
	return 0;
    }
    else if(k%2==0)
    {
	for(int i=0;i<len;i++)
	    s[len+i]=s[i];
	for(int i=0;i<2*len-1;i++)
	{
	    int cnt=1;
	    while(s[i]==s[i+1]&&i<2*len-1)
		cnt++,i++;
	    ans1+=cnt/2;
	}
	ans+=(k-1)*(ans1-ans);
    }
    else
    {
	for(int i=0;i<len;i++)
	    s[len+i]=s[i],s[2*len+i]=s[i];
	for(int i=0;i<3*len-1;i++)
	{
	    int cnt=1;
	    while(s[i]==s[i+1]&&i<3*len-1)
		cnt++,i++;
	    ans1+=cnt/2;
	}
	ans+=(k-1)/2*(ans1-ans);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int count = 0;
  string s;
  char pos = 'A';

  cin >> s;
  for (int i = 0; i != s.size(); i++) {
    if (s[i] <= pos) count++;
    pos = s[i];
  }

  cout << count << endl;
}



Measured memory_bytes: 3204
N, M = list(map(int, input().split()))

Lmax = 0
Rmin = N
for i in range(M):
    L, R = list(map(int, input().split()))
    Lmax = max(Lmax, L)
    Rmin = min(Rmin, R)

print(max(Rmin - Lmax +1, 0))

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main()
{
	char a[101];
	int i,k,s;
	s=0;
	scanf("%s",a);
	k=strlen(a);
	for(i=0;i<k;i++){
	if(a[i]!=a[k-i-1]) {	s++; }
}
	printf("%d\n",s/2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

const ll mod = 1'000'000'007;

auto main (void) -> int {
  int n;
  cin >> n;

  vector<int> a (n);
  for (auto i = 0; i < n; i++) cin >> a[i];

  ll tmp_0 = 0;
  ll tmp_1 = 0;

  for (auto i = 0; i < n; i++) {
    ll c  = static_cast<ll> (a[i]);
    tmp_0 = (tmp_0 + c) % mod;
    tmp_1 = (tmp_1 + c * c) % mod;
  }
  tmp_0 = (tmp_0 * tmp_0) % mod;

  ll b = tmp_0 < tmp_1 ? tmp_0 - tmp_1 + mod : tmp_0 - tmp_1;

  if (b % 2 != 0) {
    cout << (b + mod) / 2 << endl;
  }
  else {
    cout << b / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <algorithm>
#define hmm "\n"
#define test() int t; cin>>t; while(t--)
#define ll long long int
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define mod 1000000007ll
using namespace std;
ll fact[2000006];
ll bigmod(ll b, ll p)
{
    if(!p)return 1ll;
    ll ret= bigmod(b, p/2);
    ret= (ret*ret)%mod;
    if(p&1ll)return ret= (ret*b)%mod;
    return ret;
}
ll ncr(ll n, ll r)
{
    ll nume= fact[n];
    ll deno= (fact[n-r]*fact[r])%mod;
    return (nume*bigmod(deno, mod-2))%mod;
}
int main()
{
    fastIO
    fact[0]= 1ll;
    for(ll i=1; i<=2000000; i++)
    fact[i]= (fact[i-1]*i)%mod;
    int n, m, cnt= 0;
    scanf("%d %d", &n, &m);
    if(n<m)swap(n, m);
    int tot= (n+m)/3;
    while(n>0 && m>0 && 2*n>m)n--, n--, m--, cnt++;
    if(2*n==m)printf("%lld\n", ncr(tot, cnt));
    else puts("0");
    return 0;
}

Measured memory_bytes: 15872
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(15000)
n = int(sys.stdin.readline())

ret = []
inp = sys.stdin.readlines()
G = [None]*(n+1)
depths = [-1]*(n+1)

for i in range(1,n+1):
  v = list(map(int,inp[i-1].split()))
  G[v[0]] = list(map(int,v[2:]))
#print(G)

nodes = [1]
depth = 0
while nodes:
  new = []
  for i in nodes:
    if depths[i] == -1:
      depths[i] = depth
      new += G[i]
    #print(i,nodes,depth,depths)
  depth += 1
  nodes = new

for i in range(1,n+1):
  print(i,depths[i])


Measured memory_bytes: 5632
#include<stdio.h>
main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if(a<0)
    {
        if(b<0)
        {
            if((b-a+1)%2!=0) printf("Negative");
            else printf("Positive");
        }
        else printf("Zero");
    }
    else if(a==0) printf("Zero");
    else printf("Positive");
}


Measured memory_bytes: 128
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        for (int i = 0; i < h; i++) {
            String line = sc.next();
            System.out.println(line);
            System.out.println(line);
        }
    }
}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
#include<unordered_set>
using namespace std;
#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;

LL dist[10004][210][3];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, M, X; cin >> N >> M >> X;
	V<int>T(N);
	FOR(i, 0, N) {
		cin >> T[i];
	}
	V<int>A(M), B(M), D(M);
	using PII = pair<int, int>;
	V<V<PII>>G(N);
	FOR(i, 0, M) {
		int a, b, d;
		cin >> a >> b >> d;
		a--, b--;
		G[a].push_back({ b,d });
		G[b].push_back({ a,d });
	}
	const LL LINF = 1e18;
	fill(**dist, **dist + 10004 * 210 * 3, LINF);
	dist[0][X][0] = 0;
	// 残り[X)分はダメ
	using tp = tuple<int, int, int, int>;
	priority_queue<tp, V<tp>, greater<tp>>q;
	q.push(tp( 0,0,X,0 ));
	while (!q.empty()) {
		// 道を何度も使うことは許可されている
		int d, v, left, t;
		tie(d, v, left, t) = q.top(); q.pop();
		if (dist[v][left][t] < d)continue;
		for (const auto &nxeg : G[v]) {
			int nx = nxeg.first;
			int cost = nxeg.second;
			if (t == 0 && T[nx] == 2) {// 変化
				if (cost >= left) {
					if (dist[nx][X][2] > d + cost) {
						dist[nx][X][2] = d + cost;
						q.push(tp(d + cost,nx,X,2 ));
					}
				}
			}
			if (t == 2 && T[nx] == 0) {// 変化
				if (cost >= left) {
					if (dist[nx][X][0] > d + cost) {
						dist[nx][X][0] = d + cost;
						q.push(tp( d + cost,nx,X,0 ));

					}
				}
			}
			// 同じか平常からの変化でXになる
			if (T[nx] != 1) {// left to X
				if ((t != 1 && T[nx] == t) || (t == 1 && T[nx] != 1)) {
					if (dist[nx][X][T[nx]] > d + cost) {
						dist[nx][X][T[nx]] = d + cost;
						q.push(tp(d + cost,nx,X,T[nx] ));
					}
				}
			}


			// to ふつう 状態は維持
			if (T[nx] == 1) {
				int nt = t;
				if (cost >= left)nt = 1;
				int nleft = max(0, left - cost);
				if (dist[nx][nleft][nt] > d + cost) {
					dist[nx][nleft][nt] = d + cost;
					q.push(tp( d + cost,nx,nleft,nt ));
				}

			}
		}
	}


	LL ans = LINF;
	FOR(i, 0, 201)FOR(j, 0, 3) {
		ans = min(ans, dist[N - 1][i][j]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53484
import bisect
 
N = int(input())
Ls = list(map(int, input().split(" ")))
Ls.sort()
 
ans = 0
 
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = bisect.bisect_left(Ls,Ls[i]+Ls[j])
    ans += k - (j + 1)
       
print(ans)

Measured memory_bytes: 79796
sx,sy,tx,ty=map(int,input().split())
ans=""
d=(tx-sx)+(ty-sy)#sとtの距離
#1週目　最短距離
for i in range(2*d):
    if i<=(tx-sx)-1:
        ans+="R"
    elif i<=d-1:
        ans+="U"
    elif i<=(d-1)+(tx-sx):
        ans+="L"
    else:
        ans+="D"
#print(ans)
#2週目 外周
for j in range(2*(d+4)):
    if j==0:
        ans+="D"
    elif j<=(tx-sx)+2-1:
        ans+="R"
    elif j<=(d+4)-1-1:
        ans+="U"
    elif j<=(d+4)-1:
        ans+="L"
    elif j<=(d+4)-1+1:
        ans+="U"
    elif j<=(d+4)-1+1+(tx-sx+1):
        ans+="L"
    elif j<=2*(d+4)-1-1:
        ans+="D"
    else:
        ans+="R"
print(ans)

Measured memory_bytes: 9260
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define NUM 1001

ll N,K;
ll dp[NUM][NUM];

ll recursive(ll num_ball,ll num_box){

	if(dp[num_ball][num_box] != -1)return dp[num_ball][num_box];

	if(num_ball == 0 || num_box == 1)return 1;

	ll ret = 0;

	for(ll next_box = 1; next_box <= num_box; next_box++){
		if(next_box > num_ball)break;
		ret += recursive(num_ball-next_box,next_box);
		ret %= MOD;
	}

	return dp[num_ball][num_box] = ret;
}

int main(){

	scanf("%lld %lld",&N,&K);

	if(N < K){
		printf("0\n");
		return 0;
	}

	N -= K;

	for(ll i = 0; i <= N; i++){
		for(ll p = 0; p <= K; p++){
			dp[i][p] = -1;
		}
	}

	printf("%lld\n",recursive(N,K));

	return 0;
}




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

using namespace std;

int main(){
 
string s,w[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

cin >> s;
int ans;
for (int i = 0; i < 7; ++i)
{
   if (s == w[i])
   {
      ans = i;
   }
}

cout << 7-ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int ans=0;
  while(n%10==0) n/=10;
  if(n==1) cout<<10<<endl;
  else{
    while(n){
      ans+=n%10;
      n/=10;
    }
    cout<<ans<<endl;
  }

  return 0;
}

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

int main(){
    char s[4];
    cin>>s;
    if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3]){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }
}

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


int main(){
    int n;
    cin>>n;
    char c[n];int cnt=0;int i;
    cin>>c;
    for( i=0;i<n;){
    if(c[i]=='A'&& c[i+1]=='B'&&c[i+2]=='C'){
        i=i+3;
        cnt++;
    }
    else i++;
    }
    cout<<cnt;
    
return 0;
}

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

#define int long long

auto main() -> signed {
    int x, a, b;
    cin >> x >> a >> b;
    int t = -a + b;
    if(t<=0) cout << "delicious" << endl;
    else if(t<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
m = sum(s)
if  m % 10 != 0:
  print(m)
else:
  for i in range(n):
    if s[i] % 10 != 0:
      m -= s[i]
      print(m)
      sys.exit()
  print(0)  



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

int main()
{
    int a,b;
    cin >> a >>b;
    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    long long n;
    cin >> n;
    long double ans = 0, a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        ans += 1.0 / a;
    }
    ans = 1.0 / ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N+1];
  lint B[N];
  REP(i,N+1)cin>>A[i];
  REP(i,N)cin>>B[i];
  lint ans=0;
  lint D;
  REP(i,N){
    D=min(A[i],B[i]);
    ans+=D;
    B[i]-=D;
    D=min(A[i+1],B[i]);
    ans+=D;
    A[i+1]-=D;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  int l  = s.size();
  for(int i =97;i<=122;i++){
    int c =1;
    char a = i;
    for(int j=0;j<l;j++){
      c *= (s.at(j) != a);
    }
    if(c){
      cout << a << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}
        
    
    

Measured memory_bytes: 512
#include <bits/stdc++.h>
	#define ll long long
	#define f(i,a,b) for(ll i=a;i<b;i++)
	#define fi(i,a,b) for(ll i=b;i>=a;i--)
	using namespace std;
	ll mod(ll a)
	{
	if(a>0)
	return a;
	else
	return -a;
	}
	ll min(ll a,ll b)
	{
	if(a>b)
	return b;
	else
	return a;
	}
	ll gcd(ll a, ll b)
	{
	    if (b == 0)
	        return a;
	    return gcd(b, a % b);

	}
	ll max(ll a,ll b)
	{
	if(a<b)
	return b;
	else
	return a;
	}
	int main()
	{

	ll max=0,i1,n,n1,n2,i,w,j,l=0,k=0,c0=0,c1=0,c2=0,c3=0,m,t,gcd1;
	cin>>t;
	string s1,s2;
	for(i1=0;i1<t;i1++)
	{
	cin>>s1;
	if(s1=="TLE")
	c2++;
	if(s1=="AC")
	c0++;
	if(s1=="WA")
	c1++;
	if(s1=="RE")
	c3++;
	}
	cout<<"AC x "<<c0<<endl<<"WA x "<<c1<<endl<<"TLE x "<<c2<<endl<<"RE x "<<c3;
	return 0;
	}


Measured memory_bytes: 3632
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, c = list(map(int, readline().split()))

    x = [0] * (n + 1)
    v = [0] * (n + 1)

    for i in range(1, n + 1):
        x[i], v[i] = map(int, readline().split())

    right_cum = [0] * (n + 1)
    left_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_cum[i] = right_cum[i - 1] + v[i]
        left_cum[i] = left_cum[i - 1] + v[n - i + 1]

    right_nutritive = [0] * (n + 1)
    left_nutritive = [0] * (n + 1)
    right_max_cum = [0] * (n + 1)
    left_max_cum = [0] * (n + 1)

    for i in range(1, n + 1):
        right_nutritive[i] = right_cum[i] - x[i]
        left_nutritive[i] = left_cum[i] - (c - x[n - i + 1])
        right_max_cum[i] = max(right_max_cum[i - 1], right_nutritive[i])
        left_max_cum[i] = max(left_max_cum[i - 1], left_nutritive[i])

    r_temp = max(right_nutritive)
    l_temp = max(left_nutritive)
    ans = max(r_temp, l_temp)

    for i in range(1, n + 1):
        rl = right_nutritive[i] - x[i] + left_max_cum[n - i]
        lr = left_nutritive[i] - (c - x[n - i + 1]) + right_max_cum[n - i]
        ans = max(ans, rl, lr)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49244
#include<queue>
#include<cstdio>
#include<cstdlib>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct point{
	int x,y;
	bool operator<(const point &a)const{ return true; } // dummy
};

int main(){
	int w,h; scanf("%d%d",&w,&h);
	char B[100][101];
	rep(i,h) scanf("%s",B[i]);

	point s,g;
	vector<point> hole,maki;
	rep(i,h) rep(j,w) {
		if(B[i][j]=='S') s=(point){j,i};
		if(B[i][j]=='G') g=(point){j,i};
		if(B[i][j]=='M') maki.push_back((point){j,i});
		if(B[i][j]=='#') hole.push_back((point){j,i});
	}

	static int d[100][100][1<<5];
	rep(i,h) rep(j,w) rep(S,1<<maki.size()) d[i][j][S]=INF;
	d[s.y][s.x][0]=0;

	priority_queue< pair<int,pair<point,int> > > Q;
	Q.push(make_pair(0,make_pair(s,0)));
	while(!Q.empty()){
		int d_now=-Q.top().first;
		point p=Q.top().second.first;
		int S=Q.top().second.second; Q.pop();

		if(d_now>d[p.y][p.x][S]) continue;
		if(p.x==g.x && p.y==g.y && S==(1<<maki.size())-1) break;

		int cost=1;
		rep(i,hole.size()) cost=max(cost,max(4-max(abs(p.x-hole[i].x),abs(p.y-hole[i].y)),1));

		rep(k,4){
			int xx=p.x+dx[k],yy=p.y+dy[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]!='#'){
				int S2=S;
				rep(i,maki.size()) if(xx==maki[i].x && yy==maki[i].y) S2|=1<<i;

				int d2=d[p.y][p.x][S]+cost;
				if(d[yy][xx][S2]>d2){
					d[yy][xx][S2]=d2;
					Q.push(make_pair(-d[yy][xx][S2],make_pair((point){xx,yy},S2)));
				}
			}
		}
	}

	printf("%d\n",d[g.y][g.x][(1<<maki.size())-1]);

	return 0;
}

Measured memory_bytes: 2440
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        Map<String,Boolean> dic=new HashMap<String,Boolean>();
        int N=sc.nextInt();
        for(int i=0;i<N;i++){
            String f=sc.next();
            String str=sc.next();
            if(f.equals("insert")) dic.put(str,true);
            else System.out.println(dic.containsKey(str)?"yes":"no");
        }
    }
}


Measured memory_bytes: 252960