akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    for (int i = a; i <= b; i++) {
        string num = to_string(i);
        bool flag = true;
        for (int j = 0; j < num.size() / 2; j++) {
            if (num.at(j) != num.at(num.size()-j-1)) flag = false;
        }

        if (flag) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[10101];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",a);
	char b[1010];
	for(int i=0;i<26;i++){
		b[i]='A'+i;
		
	}
	int k=strlen(a);
	for(int i=0;i<k;i++){
		int x=(a[i]-'A'+n)%26;
		printf("%c",b[x]);
	}
	return 0;
}

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

int main() {
  int loopCount;
  string kind;
  int index;
  int existP = 0;
  int existW = 0;
  int existG = 0;
  int existY = 0;

  cin >> loopCount;

  for(index = 0; index < loopCount; index++)
  {
    cin >> kind;
    
    if (kind == "P")
    {
      existP = 1;
    }
    else if (kind == "W")
    {
      existW = 1;
    }
    else if (kind == "G")
    {
      existG = 1;
    }
    else if (kind == "Y")
    {
      existY = 1;
    }
  }
  if (existP + existW + existG + existY == 4)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    int ans = 2;
    while (ans <= N)
    {
        ans *= 2;
    }
    cout << ans / 2 << endl;
}


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

string s;
int d;

long long dp[10005][105][2];

long long f(int pos, int rem, int flag) {
    if(dp[pos][rem][flag] != -1) return dp[pos][rem][flag];
    if(pos >= s.length() and rem == 0) return dp[pos][rem][flag] = 1;
    if(pos >= s.length()) return dp[pos][rem][flag] = 0;
    
    long long res = 0;
    if(flag) {
        for(int i = 0; i < s[pos]-'0'; i++) {
            res = (res + f(pos+1, (rem+i)%d, 0))%MOD;
        }
        res = (res + f(pos+1, (rem+(s[pos]-'0'))%d, 1))%MOD;
    }
    else {
        for(int i = 0; i <= 9; i++) {
            res = (res + f(pos+1, (rem+i)%d, 0))%MOD;
        }
    }
    return dp[pos][rem][flag] = res;
}


int main() {
	// your code goes here
	cin >> s;
	cin >> d;
	
	memset(dp, -1, sizeof dp);
	cout << (f(0, 0, 1)+MOD-1)%MOD;
	return 0;
}


Measured memory_bytes: 17408
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e15;

vector<ll> h;

class DisjointSet{
    public:
    vector<ll> rank,p,val;
    DisjointSet(){}
    DisjointSet(ll size){ //作られうる木の頂点数の最大値を入れる。
        rank.resize(size,0);
        p.resize(size,0);
        val.resize(size,0);
        rep(i,size) makeSet(i);
        /*rep(i,size){
            val[i]=h[i];
        }*/
    }
    void makeSet(ll x){ //xだけが属する木を作る。
        p[x]=x;
        rank[x]=0;
    }
    bool same(ll x,ll y){ //xとyが同じ木に属するかどうか
        return findSet(x)==findSet(y);
    }
    void unite(ll x, ll y){
        link(findSet(x),findSet(y));
    }
    void link(ll x, ll y){ //rankが大きい方の根に小さい方の根をつける。
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++; //xとyの木のrankが同じであれば、統合するとrankが1増える。
            }
        }
        val[x]=max(val[x],val[y]);
        val[y]=max(val[x],val[y]);
    }
    ll findSet(ll x){ //xが属する木の根の番号を返す
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    h.resize(n);
    //DisjointSet ds=DisjointSet(n);
    
    rep(i,n){
        cin >> h[i];
        //ds.val[i]=h[i];
    }
    vector<vector<ll>> b(n);
    rep(i,m){
        ll p,q;
        cin >>p >> q;
        p--;
        q--;
        b[p].push_back(q);
        b[q].push_back(p);
        
    }
    ll ans=0;
    rep(i,n){
        bool ok=true;
        for(auto x:b[i]){
            if(h[i]<=h[x]){
                ok=false;
                break;
            }
        }
        if(ok) ans++;
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9856
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for a_, b_ in zip(a, b):
    if a_ > b_:
        cnt += a_ - b_
    else:
        cnt -= (b_ - a_) // 2
if cnt <= 0:
    print('Yes')
else:
    print('No')


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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;

int main ()
{
    lli m,n;
    scll(m,n);
    lli a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
   lli v[n-1];
   lli sum=0;
    for(int i=1;i<n;i++)
    {
        sum=abs(a[i]-a[i-1]);
        v[i-1]=sum;
    }
    sort(v,v+n-1);
    lli ans=0;
    for(int i=0;i<n-m;i++)
    {
        ans+=v[i];
        //cout << ans <<endl;
    }
    pf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		while (a%2 == 0)
		{
			a/=2;
			cnt++;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    string S; cin >> S;
    int t = 0;
    for (int i = 0; i < S.size(); i++) t += S[i] - '0';
    if (t % 9) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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


using namespace std;


int main() {
    int N;
    cin >> N;
    
    vector<int> prime_list;
    prime_list.push_back(2);
    
    int num = 2;
    while(num <= 55555){
        bool flag = false;
        for(int i = 0; i < prime_list.size(); ++i){
            if(num % prime_list[i] == 0){
                flag = true; break;
            }
        }
        if(!flag){
            prime_list.push_back(num);
        }
        ++num;
    }
    
    int pos = 0;
    
    vector<int> ans;
    
    while(ans.size() < N){
        if(prime_list[pos] % 5 == 1){
            ans.push_back(prime_list[pos]);
        }
        ++pos;
    }
    
    for(auto e:ans){
        cout << e << " ";
    }
    cout << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int N, M;
using namespace std;
typedef pair<int, int> P;
vector<P> dems(0);


int main(){
    cin >> N >> M;
    int temp1, temp2;
    for (int i = 0; i < M; i++){
        cin >> temp1 >> temp2;
        dems.push_back(P(temp1, temp2));
    }
    sort(dems.begin(), dems.end(), [](const P x, const P y){return x.second < y.second;});
    //昇順にソート
    int cnt = 0;
    int i, prev  = 0;
    for (i = 0; i < M; i++){
        if (prev <= dems.at(i).first){
          	//prevで切れてない奴だった時
            prev = dems.at(i).second;
          	cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	string c;
	cin>>c;
	if(c[a]!='-')
	{
		cout<<"No\n";
		return 0;
	}
	c[a]='1';
	for(int i=0;i<=a+b;i++)
	{
		if(c[i]<'0'||c[i]>'9')
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
	
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint H,W;
    cin >> H >> W;
    lint Hodd=(H+1)/2;
    lint Heven=H/2;
    if(H==1 || W==1) cout << 1 << endl;
    else cout << Hodd*((W+1)/2)+Heven*(W/2) << endl;
}


Measured memory_bytes: 256
import fractions
a, b, c, d = map(int, input().split())
under_b = b // c + b // d - b // (c * d // fractions.gcd(c, d))
under_a = (a - 1) // c + (a - 1) // d - (a - 1) // (c * d // fractions.gcd(c, d))
print(b - (a - 1) - (under_b - under_a))

Measured memory_bytes: 5728
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    int n;
    string s;
    int tmp0;
    int tmp1;
    int tmp2;
    int ans=0;
    vector<int> bin(1000, 0);

    cin >> n >> s;
    for(int i=0; i<=9; i++){
        tmp0 = s.find(to_string(i));
        //cout << i << " " << tmp0 << endl;
        for(int j=0; j<=9; j++){
            if(tmp0==-1 || tmp0==n-2)break;
            tmp1 = s.find(to_string(j), tmp0+1);
            //cout << i << " " << j << " " << tmp0 << " " << tmp1 << endl;
            for(int k=0; k<=9; k++){
                if(tmp1==-1 || tmp1==n-1)break;
                tmp2 = s.find(to_string(k), tmp1+1);
                if(tmp2==-1)continue;
                //cout << i << " " << j << " " << k << " " << tmp0 << " " << tmp1 << " " << tmp2 << endl;   
                if(bin[i*100+j*10+k]==0){
                    bin[i*100+j*10+k]=1;
                }
            }
        }
    }
    for(int i=0; i<1000; i++){
        ans += bin[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N, M, max = 0, tmp;
    string s[101], t[101];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> s[i];
    cin >> M;
    for (int i = 0; i < M; i++) cin >> t[i];
    for (int i = 0; i < N; i++) {
        tmp = 0;
        for (int j = 0; j < N; j++)
            if (s[i] == s[j]) tmp++;
        for (int j = 0; j < M; j++)
            if (s[i] == t[j]) tmp--;
        if (tmp > max) max = tmp;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
def solve1(x):
    for c in range(1, x+1):
        if 100*c <= x <= 105*c:
            print(1)
            exit()
    print(0)

def solve2(x):
    dp = [0 for _ in range(100000+1)]
    for i in range(100, 106):
        dp[i] = 1

    for i in range(100, 100000+1):
        for j in range(6):
            if dp[i-(100+j)]:
                dp[i] = 1
    print(dp[x])

x = int(input())
solve2(x)

Measured memory_bytes: 44784
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define rin(i,n,k) for(int i=0;i<n;i+=k)
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100010;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];
bool mark[maxn],bpart[maxn];
string s,s1,s2;
map <string ,int> mp;
bool markchaild[maxn];

int32_t main() {
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        h[x]+=y;
        if(mark[x]==0){
           v1.pb(x);
           mark[x]=1;
        }
    }
    sort(v1.begin(),v1.end());
    ans=h[v1[0]];
    int i=1;
    while(ans<k){
        ans+=h[v1[i]];
        i++;
    }
    cout<<v1[i-1];
    return 0;
}


Measured memory_bytes: 5500
using System;
using System.Linq;

namespace ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] a = new int[x[0],x[1]]; int[,] b = new int[x[1],x[2]];
            for (int i = 0; i < x[0]; i++)
            {
                int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[1]; j++)
                {
                    a[i,j] = n[j];
                }
            }
            for (int i = 0; i < x[1]; i++)
            {
                int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < x[2]; j++)
                {
                    b[i,j] = n[j];
                }
            }
            for (int i = 0; i < x[0]; i++)
            {
                long n = 0;
                for (int j = 0; j < x[2] - 1; j++)
                {
                    n = 0;
                    for (int k = 0; k < x[1]; k++)
                    {
                        n += a[i,k] * b[k,j];
                    }
                    Console.Write(n + " ");
                }
                n = 0;
                for (int k = 0; k < x[1]; k++)
                {
                    n += a[i,k] * b[k,x[2] - 1];
                }
                Console.WriteLine(n);
            }
        }
    }
}


Measured memory_bytes: 9900
import java.util.Scanner;

class Main{
	public static void main (String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int s = stdIn.nextInt();
		int i = s % 100;
		int k = s / 100;
		if(i>=1 && i<=12 && k>=1 && k<=12)
			System.out.println("AMBIGUOUS");
		else if(k>=1 && k<=12)
			System.out.println("MMYY");
		else if(i>=1 && i<=12)
			System.out.println("YYMM");
		else
			System.out.println("NA");
	}
}

Measured memory_bytes: 21716
#include <iostream>
using namespace std;
 
int main(){

    int h ,n, sum, tempA;

	cin >> h >> n;

    sum = 0;
    for(int i=0; i<n; i++){
        cin >> tempA;
        sum += tempA;
    }
    
    if (h > sum)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
    let temp = input.trim().split('\n');
    let n = parseInt(temp[0]);
    let h = temp[1].split(' ').map((v)=>parseInt(v));
    
    let cv = 1;
    let maxn = h[0];
    for(let i=1;i<n;i++){
        if(maxn<=h[i]) cv++;
        maxn = Math.max(h[i],maxn);
    }
    console.log(cv);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
N = int(input())
arr = list(int(x) for x in input().split())
flag = [-1] * N
ans = []

# N-1から0までループ
for i in range(N-1,-1,-1):
    # ボールの個数
    sum = 0

    # iの倍数のボールの数を確かめる
    for j in range(i,N,i+1):
        # 自身は省く
        if j == i:
            continue
        else:
            if flag[j] == 1:
                sum += 1

    # ボールを入れるかの判定
    if sum % 2 == arr[i]:
        flag[i] = 0
    else:
        flag[i] = 1
        
        # ボールを入れるインデックスを追加
        ans.append(i+1)

# ボールを何個入れたか
num = len(ans)

if num == 0:
    print(num)
else:
    print(num)
    print(*ans)



Measured memory_bytes: 14092
import itertools
num = int(input())
lis = list(map(int,input().split()))
tri = list(itertools.combinations(lis,3))
count = 0

for i in range(len(tri)):
    a = tri[i][0]
    b = tri[i][1]
    c = tri[i][2]
    if len(tri[i]) == len(set(tri[i])):
        if a+b > c and b+c > a and a+c > b:
            count += 1

print(count)

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

// types - only for stuff used a lot 
using ll = long long;
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif
	
	int n; cin>>n;
	int gr[n];
	int t = 0;
	if (n&1) f(i,0,n-1) gr[i] = gr[n-2-i] = t++, gr[n-1] = t++;	
	else f(i,0,n) gr[i] = gr[n-1-i] = t++;
	int m = 0;
	stringstream ss;
	f(i,0,n) f(j,i,n) if (gr[i] != gr[j]) {
		ss << i+1 << " " << j+1 << endl;
		m++;
	}
	cout << m << endl << ss.str();

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}



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

int main() {
  int a, b, c,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, 4){
        if(s[i] == '+'){
            ans++;
        }
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
#define MAX 1000000
 
char Prime[MAX];
 
void PrimeSearch_Eratos( void ) //エラトステネスの篩
{
    int i = 0, j = 0;
 
    for( i = 0 ; i < MAX ; i ++ ) Prime[i] = 1;
 
    Prime[0] = 0;
    Prime[1] = 0;
 
    for( i = 2 ; i <= sqrt( ( double )MAX ) + 1 ; i ++ ) //doubleにキャストしないと
    {                                                   //オーバーロードがなんたら
        if( !Prime[i] ) continue;                       //（　゜д゜）ポカン
 
        for( j = i * 2 ; j <= MAX ; j += i )
        {
            Prime[j] = 0;
        }
    }
 
    return ;
}
 
int main( void )
{
    int n = 0;
 
    PrimeSearch_Eratos();
 
    while( scanf( "%d", &n ) != EOF )
    {
        int i = 0;
        int Count = 0;
 
        for( i = 0 ; i <= n ; i ++ )
        {
            if( Prime[i] ) Count ++;
        }
 
        printf( "%d\n", Count );
    }
 
    return 0;
}

Measured memory_bytes: 1572
#include <stdio.h>

int cal(int,int);

int main()
{
  int x,y,ano,fin;

  scanf("%d%d",&x,&y);
  if(x>y)
    {
      ano=x%y;
      fin=cal(ano,y);
    }
  else if(x<y)
    {
      ano=y%x;
      fin=cal(ano,x);
    }
  else
    fin=x;
  printf("%d\n",fin);
  return 0;
}

int cal(int ano,int ex)
{
  int result,i;
  for(i=ano;i>0;i--)
    {
      if(ano%i==0 && ex%i==0)
	{
	  result=i;
	  break;
	}
    }
  return result;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    int n;
    cin>>n;
    int i,j,k,x;
    int a[10010]={0};
    for(i=1;i<100;++i){
        for(j=1;j<100;++j){
            for(k=1;k<100;++k){
                x=i*i+j*j+k*k+i*j+j*k+k*i;
                if(x<10010)a[x]++;
            }
        }
    }
    for(i=1;i<=n;++i)cout<<a[i]<<endl;
}

Measured memory_bytes: 3632
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
dp = [[False]*(F+1) for i in range(F+1)]
dp[0][0] = True
for f in range(F+1):
  for s in range(F+1):
    if dp[f][s]:
      if f+C<=F and s+C<=F:
        dp[f+C][s+C] = True
      if f+D<=F and s+D<=F:
        dp[f+D][s+D] = True
      if f + A <= F:
        dp[f+A][s] = True
      if f + B <= F:
        dp[f+B][s] = True

ans = (float('inf'), 0)
for f in range(F+1):
  for s in range(F+1):
    if dp[f][s]:
      if s*100 <= E*(f-s):
        if ans[1]*f < ans[0]*s:
          ans = (f, s)

if ans[0] < float('inf'):
  print(*ans)
else:
  print(A, 0)

Measured memory_bytes: 106844
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m;
int main(){
	ll a,b,c,x,y;
	in4(a,b,c,x);in(y);c*=2;
	ll ans=a*x+b*y;
	if(x>y)ans=min(ans,c*y+a*(x-y));
	 else ans=min(ans,c*x+b*(y-x));
	ans=min(ans,c*max(x,y));
	outl(ans);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define OO -1
using namespace std;

int dp[2000][2000];
bool est_obstacle[2000][2000];
int nb_lignes, nb_colonnes;

int nb_chemins(int x, int y)
{
    if (dp[x][y] != OO)return dp[x][y];
    if (est_obstacle[x][y]) return 0;
    
    dp[x][y] = 0;
    if (x < nb_lignes) dp[x][y] += nb_chemins(x + 1, y);
    if (y < nb_colonnes)dp[x][y] += nb_chemins(x, y + 1);
    dp[x][y] %= int(pow(10, 9)+7);
    return dp[x][y];
}

signed main()
{
    cin >> nb_lignes >> nb_colonnes;
    for (int i=0;i<nb_lignes;++i)
        for (int j=0;j<nb_colonnes;++j)
        {
            char a;
            cin >> a;
            est_obstacle[i][j] = ( a == '#');
            dp[i][j] = OO;
        }
    dp[nb_lignes-1][nb_colonnes-1] = 1;
    cout << nb_chemins(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 12544
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;






    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solv() {
    int n;
    int sum = 0;
    vector<int> x;
    cin >> n;
    rep(i, n) {
        int buf;
        cin >> buf;
        x.push_back(buf);
        sum += buf;
    }
    double rate;
    if (sum > 0)
        rate = 0.5;
    else {
        rate = -0.5;
    }
    int avg = sum / (double)n + rate;
    // cout << avg << endl;
    int cost = 0;
    rep(i, n) {
        int buf;
        buf = (x[i] - avg);
        cost += buf * buf;
    }
    cout << cost << endl;
}

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

Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		sc.nextLine(); // nextInt()??????????????£?????????"\n"????¶????????????????

		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];

		for (int i=0; i < n; i++) {

			String[] data = sc.nextLine().split(" ");

			for (int j=0; j < m; j++) {
				A[i][j] = Integer.parseInt(data[j]);
			}

		}

		for (int j=0; j < m; j++) {

			String[] data = sc.nextLine().split(" ");

			for (int k=0; k < l; k++) {
				B[j][k] = Integer.parseInt(data[k]);
			}

		}

		// C[i][k] = sigma(j : 0 -> m) A[i][j] * B[j][k]

		for (int i=0; i < n; i++) {

			for (int k=0; k < l; k++) {

				for (int j=0; j < m; j++) {
					C[i][k] += A[i][j] * B[j][k];
				}

			}

		}

		for (int i=0; i < n; i++) {
			for (int k=0; k < l-1; k++) {
				System.out.print(C[i][k] + " ");
			}
			System.out.println(C[i][l-1]);
		}

	}

}

Measured memory_bytes: 35224
n,c=[int(i) for i in input().split()]
x=[[0 for i in range(2)] for j in range(n)]
for i in range(n):
    x[i]= [int(i) for i in input().split()]
x.sort(key=lambda x:x[0])

state=0

left_wa=[0 for i in range(n)]
right_wa=[0 for i in range(n)]

for i in range(n):
    if i==0:
        left_wa[i]=x[i][1]-abs(x[i][0]-state)
    else:
        left_wa[i]=left_wa[i-1]+x[i][1]-abs(x[i][0]-state)
    state=x[i][0]

state=c

for i in range(n):
    if i==0:
        right_wa[i]=x[n-1-i][1]-abs(x[n-1-i][0]-state)
    else:
        right_wa[i]= right_wa[i-1]+x[n-1-i][1]-abs(abs(c-x[n-1-i][0])-abs(state))
    state=c-x[n-1-i][0]

kcal=0

m_right=[0 for i in range(n+1)]
m_left=[0 for i in range(n+1)]

for i in range(n+1):
    if i!=0:
        m_right[i]=max(m_right[i-1], right_wa[i-1])
        m_left[i]=max(m_left[i-1], left_wa[i-1])

#print(m_left)

for i in range(n):
    if i!=n-1:
#        right=max(right_wa[:n-1-i])-x[i][0]
        right= m_right[n-1-i]-x[i][0]
    else: right=0
    kcal=max(kcal, left_wa[i]+max(0, right))

for i in range(n):
    if i!=n-1:
#        left=max(left_wa[:n-1-i])-abs(c-x[n-i-1][0])
       left=m_left[n-1-i]-abs(c-x[n-i-1][0])

    else: left=0
    kcal=max(kcal, right_wa[i]+max(0, left))


print(kcal)


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

using namespace std;

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

void dfs(int x, int y, long long &cnt_b, long long &cnt_w, const vector<string> &g,
         vector<vector<int>> &vis) {
    int n = g.size(), m = g[0].size();
    vis[x][y] = 1;
    cnt_b += (g[x][y] == '#');
    cnt_w += (g[x][y] == '.');
    for (int i = 0; i < 4; ++i) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx >= 0 && nx < n && ny >= 0 && ny < m) {
            if (!vis[nx][ny] && g[nx][ny] != g[x][y]) {
                dfs(nx, ny, cnt_b, cnt_w, g, vis);
            }
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for (int i = 0; i < H; ++i) {
        cin >> grid[i];
    }
    long long res = 0;
    vector<vector<int>> vis(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (!vis[i][j]) {
                long long cur_b = 0, cur_w = 0;
                dfs(i, j, cur_b, cur_w, grid, vis);
                res += cur_b * cur_w;
            }
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  int N, M;
  cin >> N >> M;
  int x = 1900*M+100*(N-M);
  double p = 1/pow(2, M);
  /*
  かかる時間の期待値をEとする
  E == (今回の提出にかかる時間)+(その後かかる時間の期待値)
    E == x + ?
  (その後かかる時間の期待値) == (成功する確率)*(成功時にその後かかる時間の期待値)+(失敗する確率)*(失敗時にその後かかる時間の期待値)
    ? == p*0 + (1-p)*E
  よって
    E == x + (1-p)*E
    E == x/p
  */
  cout << x/p << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, k;
    cin >> n >> k;
    double cc = 0.0;
    if (n >= k)
    {
        repi(i, 1, k)
        {
            int cei = ceil(log2(double(k) / i));
            cc += pow(0.5, cei);
        }
        cc *= double(1.0/ n);
        cc += double(n - k + 1) / n;
    }
    else
    {
        repi(i, 1, n + 1)
        {
            int cei = ceil(log2(double(k) / i));
            cc += pow(0.5, cei);
        }
        cc *= double(double(1) / n);
    }
    printf("%.12lf\n", cc);
    return 0;
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll> > vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
int grid[100][100];
int a,b;

void red(){
    for(int i = 0;i < 50;i++){
        for(int j = 0;j < 100;j++)grid[i][j] = 1;
    }
    if(a == 1)return;
    int red = 0;
    for(int i = 0;i < 50;i+=2){
        for(int j = 0;j < 100;j+=2){
            grid[i][j] = 0;
            //cout << i << " " << j << " " << red << " " << a-1 <<endl;
            if(++red == a - 1) return;
        }
    }
}

void blue(){
    int blue = 0;
    if(b == 1)return;
    for(int i = 51;i < 100;i+=2){
        for(int j = 0;j < 100;j+=2){
            grid[i][j] = 1;
            
            if(++blue == b - 1)return;
        }
    }
}

void print(){
    printf("100 100\n");
    for(int i = 0;i < 100;i++){
        for(int j = 0;j < 100;j++){
            printf("%c",(grid[i][j] == 0)?'.':'#');
        }
        printf("\n");
    }
}

void solve(){
    cin >> a >> b;
    red();
    blue();
    print();
}

int main(void){
    solve();
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){

    while(true){

        int H, W, i, j;

        cin >> H >> W;

        if(H == 0 && W == 0)break;

        for(i = 0;i < H;i++){

           for(j = 0;j < W;j++){
               //?\???°???????????????
               if(i % 2 == 0){

                   if(j % 2 == 0)cout << "#";
                   else{
                       cout << ".";
                   }
               }
               //??¶??°???????????????
               else{

                   if(j % 2 == 0)cout << ".";
                   else{
                       cout << "#";
                   }

               }
           }
           
           cout << endl;//??????

        }

        cout << endl;//????????¢????????????

    }

return 0;

}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

vint primeSieve(int n)
{
    vint ret;
    ret.reserve(n);
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            ret.pb(i);
            for (int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return ret;
}

void Main()
{
    auto pl = primeSieve(100005);
    bool is_prime[100005];
    arrayFill(is_prime, false);
    rep(i, pl.size())
    {
        is_prime[pl[i]] = true;
    }

    bool is_ok[100005];
    arrayFill(is_ok, false);
    for (int i = 1; i <= 100001; i += 2)
    {
        if (is_prime[i] && is_prime[(i + 1) / 2])
        {
            is_ok[i] = true;
        }
    }
    vint sum(100005, 0);
    rep(i, 100001)
    {
        if (is_ok[i])
        {
            sum[i + 1] = sum[i] + 1;
        }
        else
        {
            sum[i + 1] = sum[i];
        }
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        ++r;
        cout << sum[r] - sum[l] << endl;
    }
}

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


Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
int main(){
  int x,y,d,a1,a2;
  scanf("%d%d",&x,&y);

  if(x>y){
    a1=x;
    a2=y;
  }else{
    a1=y;
    a2=x;
  }
  while(1){
    
    if(a1%a2==0){
      break;
      
    }else{
      d=a1%a2;
      a1=a2;
      a2=d;
    }
  }
  
  printf("%d\n",a2);
  
  return 0;
}



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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,u,v,m;

int rabbit[1000010],cat[1000010];

int rnum=0,cnum=0;
bool r[510][510];
bool c[510][510];

int main(void){
	cin >> n >> u >> v >> m;
	clr(rabbit,-1),clr(cat,-1);
	rep(i,n*n){
		int in;
		cin >> in;
		rabbit[in]=i;
	}
	rep(i,n*n){
		int in;
		cin >> in;
		cat[in]=i;
	}

	int res=-1;

	rep(loop,m){
		int in;
		cin >> in;
		if(rabbit[in]>=0){
			r[rabbit[in]/n][rabbit[in]%n]=true;
			{
				bool ok=true;
				rep(j,n) if(r[rabbit[in]/n][j]==0) ok=false;
				rnum+=ok;
			}
			if(n!=1){
				bool ok=true;
				rep(j,n) if(r[j][rabbit[in]%n]==0) ok=false;
				rnum+=ok;
			}
			if(n!=1&&rabbit[in]/n==rabbit[in]%n){
				bool ok=true;
				rep(j,n) if(r[j][j]==0) ok=false;
				rnum+=ok;
			}
			if(n!=1&&rabbit[in]/n+rabbit[in]%n==n-1){
				bool ok=true;
				rep(j,n) if(r[j][n-1-j]==0) ok=false;
				rnum+=ok;
			}
		}
		if(cat[in]>=0){
			c[cat[in]/n][cat[in]%n]=true;
			{
				bool ok=true;
				rep(j,n) if(c[cat[in]/n][j]==0) ok=false;
				cnum+=ok;
			}
			if(n!=1){
				bool ok=true;
				rep(j,n) if(c[j][cat[in]%n]==0) ok=false;
				cnum+=ok;
			}
			if(n!=1&&cat[in]/n==cat[in]%n){
				bool ok=true;
				rep(j,n) if(c[j][j]==0) ok=false;
				cnum+=ok;
			}
			if(n!=1&&cat[in]/n+cat[in]%n==n-1){
				bool ok=true;
				rep(j,n) if(c[j][n-1-j]==0) ok=false;
				cnum+=ok;
			}
		}
		if(res>=0) continue;

		if(rnum>=u&&cnum>=v)
			res=0;
		else if(rnum>=u)
			res=1;
		else if(cnum>=v)
			res=2;
	}
	if(res==1)
		cout << "USAGI" << endl;
	else if(res==2)
		cout << "NEKO" << endl;
	else
		cout << "DRAW" << endl;
	return 0;
}

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

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

using namespace std;

const int MAXN = 3000;
int a[MAXN + 1];
long long pre[MAXN + 1];
long long dp[MAXN + 1][MAXN + 1];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
        dp[i][i] = a[i];
    }
    for (int len = 2; len <= n; len++)
    {
        for (int i = 1; i + len - 1 <= n; i++)
        {
            int j = i + len - 1;
            long long sum = pre[j] - pre[i - 1];
            dp[i][j] = max(sum - dp[i + 1][j], sum - dp[i][j - 1]);
        }
    }
    cout << 2 * dp[1][n] - pre[n] << endl;
    return 0;
}


Measured memory_bytes: 70016
from itertools import product
n=int(input())
li=[[] for _ in range(n)]
A=[]
for i in range(n):
    a=int(input())
    A.append(a)
    for _ in range(a):
        x,y=map(int,input().split())
        li[i].append([x,y])
ans=0
for p in product([0, 1], repeat = n):
    f = 0
    for i in range(n):
        if f==0:
            for j in range(A[i]):
                if p[i]==1 and li[i][j][1] == 0:
                    if p[li[i][j][0] - 1] == 1:
                        f += 1
                        break
                elif p[i]==1 and li[i][j][1] == 1:
                    if p[li[i][j][0] - 1] == 0:
                        f += 1
                        break
        else:
            break
    if f==0:
        ans=max(ans,p.count(1))
print(ans)







Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct stx {
  ll S, T, X;

  stx(ll s, ll t, ll x) : S(s), T(t), X(x) {}
  bool operator<(const stx& another) const {
    return X < another.X;
  };
};

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<stx> STX;
  rep(i, N) {
    ll S, T, X;
    cin >> S >> T >> X;
    S -= X;
    T -= X;
    STX.pb(stx(S, T, X));
  }

  set<ll> s;
  map<ll, ll> m;
  vector<int> D(Q);
  rep(i, Q) {
    cin >> D[i];
    s.insert(D[i]);
  }

  sort(all(STX));

  rep(i, N) {
    auto iter = s.lower_bound(STX[i].S);
    auto last = s.lower_bound(STX[i].T);
    vector<ll> hit;
    while (iter != last) {
      hit.pb(*iter);
      iter++;
    }
    rep(j, hit.size()) {
      m[hit[j]] = STX[i].X;
      s.erase(hit[j]);
    }
  }

  rep(i, Q) {
    ll ans = m[D[i]] ? m[D[i]] : -1;
    cout << ans << endl;
  }
}

Measured memory_bytes: 29676
#include <fstream>
#include <iostream>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	bool flag1 = false;
	for (auto &i : s) {
		if (i == 'C' && !flag1) {
			flag1 = true;
		}
		if (flag1 &&i == 'F') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int BUFFSIZE = 1 << 17;

char buffer[BUFFSIZE];
int pointer = BUFFSIZE;

char Advance() {
    if (pointer == BUFFSIZE) {
        fread(buffer, 1, BUFFSIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int SIGMA = 26;
const int MAXN = 100;

int seen[SIGMA];
char s[1 + MAXN];

bool Get(int x, int y) {
    int letter = 0;
    for (int i = 1; i <= y; i++) {
        while (letter < SIGMA && seen[letter] < x)
            letter++;
        if (letter == SIGMA)
            return false;
        seen[letter] -= x;
    }
    return true;
}

bool Check(int n, int m) {
    int l1 = 1, l2 = n, one = 0, two = 0, four = 0;
    while (l1 <= l2) {
        int c1 = 1, c2 = m;
        while (c1 <= c2) {
            if (c1 == c2 && l1 == l2)
                one++;
            else
                if (c1 != c2 && l1 != l2)
                    four++;
                else
                    two++;
            c1++;
            c2--;
        }
        l1++;
        l2--;
    }
    if (!Get(4, four) || !Get(2, two) || !Get(1, one))
        return false;
    return true;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, m;
    scanf("%d%d\n", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%s\n", s + 1);
        for (int j = 1; j <= m; j++)
            seen[s[j] - 'a']++;
    }
    if (Check(n, m))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128