akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/


const long long mod = 1e+7 ;
const int N = 1e5+5;
const double PI=acos(-1);


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(ll i=l;i<m;i++)
#define frr(i,l,m) for(int i=l;i>m;i--)
# define vii vector<int>
#define vll vector<ll>
#define vpr vector<pair<ll,ll> >
#define dbg(x) cout << #x << " is " << x << endl;
#define gcd(l,r) __gcd(l,r)
#define cd complex<double>
#define vcd vector<cd>
#define clr(x) memset(x,0,sizeof(x))
/*
pow(2,20)->1e6;
pow(2,30)->1e9;
stoll - string to ll;
string with space getline(cin, str);
*/
ll pwr(ll x,ll y, ll m);
ll mult(ll a,ll b,ll m);

////
ll a[N][3],dp[N][3];
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);

int n,k;
cin>>n;
fr(i,1,n+1){cin>>a[i][0]>>a[i][1]>>a[i][2];}
dp[n][0]=a[n][0];
dp[n][1]=a[n][1];
dp[n][2]=a[n][2];
frr(i,n-1,0)
{

    fr(j,0,3){
   dp[i][j]=max(dp[i+1][(j+1)%3]+a[i][j],dp[i+1][(j+2)%3]+a[i][j]);
    }
}
cout<<max(max(dp[1][0],dp[1][1]),dp[1][2])<<endl;

return 0;

 }
 ////
 ////

ll pwr(ll x,ll y,ll m)
{ll ans=1;x=x%m;while(y){if(y&1)ans=(x*(ans%m))%m;x=(x*x)%m;y>>=1;}
return ans%mod;}
////
////
ll mult(ll x,ll y, ll m){
    ll ans=0;
    while(y){if(y&1)ans=(ans+x)%m;
x=(x+x)%m;
y>>=1;}
return ans%m;}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, c;
char b;
bool flag = true;
while(flag){
cin >> a >> b >> c;
if(b == '+')cout << a+c << endl;
else if(b == '-')cout << a-c << endl;
else if(b == '*')cout << a*c << endl;
else if(b=='/')cout << a/c << endl;
else if(b=='?') break;
}
}


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

int main(){
string str;
  	cin >> str;
  int ans=0;
  rep(i,str.size()){
  	if(str[i]!=(str[str.size()-i-1])){
    	ans++;
    }
  }
  
  cout << (ans/2) << endl;
  
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine()
  val p = StdIn.readLine().split(" ").map(_.toInt).toList
  println(if ((for ((i,j) <- (p zip p.sorted) if (i != j)) yield (i,j)).length <= 2) "YES" else "NO")
}


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

int main(){
  string s,ans;
  vector<int> A(26,0);
  cin>>s;
  for(int i = 0;i<s.size();i++){
    A.at(s.at(i)-'a')++;
  }
  char tmp = '0';
  for(int i = 0;i<26;i++){
    if(A.at(i)==0){
      tmp = i+'a';
      ans.push_back(tmp);
      break;
    }
  }
  if(tmp=='0'){
    ans = "None";
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MOD = 1e9 + 7;

void solve()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    ll dp[n];
    for(ll i=0;i<n;i++)
    {
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(ll i=0;i<n;i++)
    {
        //cout << "i = "<<i<<"\n";
        for(ll j=i+1;j <= min(n-1,i+k);j++)
        {
            //cout<<"j = "<<j<<"\n";
            dp[j] = min(dp[j] , dp[i]+abs(h[i] - h[j]));
           /* for(ll i=0;i<n;i++)
            {
                cout<<dp[i]<<" ";
            }
            cout<<'\n';
            */
        }
    }
    
    //cout<<"\n";
    cout<<dp[n-1]<<"\n";
}

//MAIN 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5144
def is_pal(x):
    return x == x[::-1]

if __name__ == '__main__':
    #s = input().rstrip().split(' ')
    s = input()
    N = len(s)
    print('Yes' if is_pal(s) and is_pal(s[:int((N-1)/2)]) and is_pal(s[int((N+3)/2)-1:]) else 'No')


Measured memory_bytes: 2940
#!/usr/bin/env python3

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

n = I()
a = LI()
b = LI()
ans = 0
for i in range(n):
    cnt = b[i]
    if a[i] >= cnt:
        a[i] -= cnt
        ans += cnt
        continue
    else:
        ans += a[i]
        ans += min(a[i+1],(cnt - a[i]))
        a[i+1] = max(0,a[i+1] - (cnt - a[i]))
print(ans)

Measured memory_bytes: 73316
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(H);
    scanInt(W);
    vector<string> S(H);
    REP(h, H){
        cin >> S[h];
    }
    auto check = [&](int h, int w){return 0 <= h && h < H && 0 <= w && w < W;};
    auto search = [&](int h, int w){
        int count = 0;
        REP(h2, 3){
            REP(w2, 3){
                if (h2 == 1 && w2 == 1) continue;
                if (check(h + h2 - 1, w + w2 - 1) && S[h + h2 - 1][w + w2 - 1] == '#') ++count;
            }
        }
        S[h][w] = ('0' + count);
    };
    REP(h, H){
        REP(w, W){
            if (S[h][w] == '.') search(h, w);
        }
    }
    REP(h, H){
        cout << S[h] << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,x,y,a[100001]={1},b[100001]={};
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++) b[i]=1;
  for(i=0;i<m;i++){
    scanf("%d%d",&x,&y);
    if(a[x-1]==1){
      a[y-1]=1;
    }
    b[x-1]--;
    b[y-1]++;
    if(b[x-1]==0){
      a[x-1]=0;
    }
  }
  int ans=0;
  for(i=0;i<n;i++){
    ans+=a[i];
  }
  printf("%d",ans);
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int  a[10005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        cout<<a[i];
    }
    cout<<endl;
    for(int i=1;i<n;i++)
    {
        int v=a[i];
        int j=i-1;
        while(j>=0&&a[j]>v)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(int k=0;k<n;k++)
        {
            if(k)cout<<' ';
            cout<<a[k];
        }
        cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s;
    vector<int> v;
    cin >> s;
    for (int i = 0; i < s.size();i++){
        if(s[i]=='0')
            v.push_back(0);
        else if(s[i]=='1')
            v.push_back(1);
        else { 
            if(v.empty())
                continue;
            v.pop_back();
        }
    }
    for (int i = 0; i < v.size();i++){
        cout << v[i];
    }
    printf("\n");

    return 0;
}

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

void chmax(int& a, int b) {
  if (a < b) a = b;
}

int main() {
  string S;
  cin >> S;
  S += 'B';
  
  int ans = 0;
  // i スタートとしてカウント
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != 'A' && S[i] != 'C' 
        && S[i] != 'G' && S[i] != 'T') continue;
    
    int count = 1;
    for (int j = i+1; j < S.size(); j++) {
      if (S[j] == 'A' || S[j] == 'C' 
        || S[j] == 'G' || S[j] == 'T') {
        count++;
      } else {
        chmax(ans, count);
        break;
      }
    }
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
vector<ll> primes;
bool prime[10000005];
/*void SieveOfEratosthenes(int n) 
{ 
     
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000005; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=10000005; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          primes.pb(p); 
} */
void solve()
{   ll X,Y,Z;
    cin>>n;
    ll ans=0;
    ll x=n-1;
    set<ll> s1;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0) {s1.insert(i);s1.insert(x/i);}
    }   
    for(ll i=2;i*i<=n;i++)
    {   ll y=n;
        if(y%i==0)
        {   //cout<<i<<" ";
            while(y%i==0) y/=i;
            if(y%i==1) s1.insert(i);
        }
        /*if(n%i==0 && i*i!=n)
        {   
            y=n;
            while(y%i==0) y/=i;
            if(y%i==1) s1.insert(i);
        }*/
        
    }
    //for(auto x:s1) cout<<x<<" ";
    s1.erase(1);s1.insert(n);
    cout<<s1.size();
    
    
}

int main()
{   //seive();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// N M
// input! {
//     N: i32,
//     M: i32,
// }

// N
// a1, ..., aN
// input! {
//     N: i32,
//     A: [i32, N],
// }

// H W
// a11 ... a1W
// ...
// aH1 ... aHW
// input! {
//     H: i32,
//     W: i32,
//     A: [[i32, W], H],
// }

// S
// input! {
//     S: chars,
// }

const MOD: u64 = 1000000007;

fn main() {
    input! {
        N: usize,
        S: String,
    };

    let red = S.match_indices("R").count();
    let blue = N - red;

    if red > blue {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    ll mx;

    //N<B N
    if(N<B){
        mx = floor(A*N/B) - A*floor(N/B);
    }else{
    //N>=B B-1
        mx = floor(A*(B-1)/B) - A*floor((B-1)/B);
    }
    cout << mx << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
ll n, W, dp[110][MAXN];
pll va[110];
int main(){
	IOS;
	cin >> n >> W;
	for (int i = 1; i <= n; i++){
		cin >> va[i].F >> va[i].S;
	}
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= W; j++){
			if (i == 0 || j == 0){
				dp[i][j] = 0;
 			}else if(va[i].F <= j){
 				dp[i][j] = max(va[i].S + dp[i - 1][j - va[i].F], dp[i - 1][j]);
			 }else{
			 	dp[i][j] = dp[i - 1][j];
			 }
		}
	}
	cout << dp[n][W];
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 157184
s = [int(x) for x in list(input())]
n = len(s)
ans = 0

for i in range(2**(n-1)):
    nnn = [[s[0]]]
    for j in range(0, n - 1):
        if ((i>>j)&1):
            nnn[-1].append(s[j + 1])
        else:
            nnn.append([s[j + 1]])

    for nn in nnn:
        for i, val in enumerate(reversed(nn)):
            ans += val * 10 ** i

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };
int H,W;
char mapdata[110][110];
void dfs(int y,int x){
    char tmp = mapdata[y][x];
    mapdata[y][x] = '.';
    rep(i,4){
        int ny = y+dy[i];
        int nx = x+dx[i];
        //if (nx < 0 || nx >= W || ny < 0 || ny >= H || c == mapdata[ny][nx]) continue;
        if(0 <= ny && ny < H && 0 <= nx && nx < W && tmp == mapdata[ny][nx]) dfs(ny,nx);
        //dfs(ny,nx);
    }
}
int main(){
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        int ans = 0;
        rep(i,H) cin >> mapdata[i];
        rep(i,H){
            rep(j,W){
                /*rep(k,H) { 
                    rep(l,W) cout << mapdata[k][l];
                    cout << endl;
                }*/
                if(mapdata[i][j] != '.'){
                dfs(i,j);
                ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3476
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  case class Rotation(run: Dice => Dice){
    def apply(d: Dice): Dice = run(d)
    def compose(other: Rotation): Rotation = Rotation(run compose other.run)
  }

  object Rotation {
    def id = Rotation(d => d)
    def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rotation: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rotation).fold(id)(_ compose _)

    def enumerateTop: Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = {
      val ax = axial(ccw)
      enumerateTop.flatMap(e => ax.map(e compose _))
    }
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    //val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)

    for(i <- 1 to n){
      val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
      println(Dice(pip).all.filter(d => d.pip(0) == a && d.pip(1) == b)(0).pip(2))
    }
  }

}

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

bool search(int S[], int n,int num) {
	int min = 0;
	int max = n;
	int pos = n / 2;
	while (max - min > 1){
		if (S[pos] == num) {
			return true;
		}
		if (S[pos] > num) {
			max = pos;
			pos -= (min + pos) / 2 + (min + pos) % 2;
		}
		else {
			min = pos;
			pos += (max - pos) / 2 + (max - pos) % 2;
		}
	}
	return false;
}

int main() {
	
	int n, q;
	int S[100000];
	int T[50000];
	int cnt = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T[i];
	}

	for (int i = 0; i < q; i++) {
		if (search(S, n, T[i]))cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  }
  else if (6 <= a && a <= 12) {
    cout << b / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


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

def solve(H: "List[int]", M: "List[int]", K: int):
    d_start = datetime.datetime(year=2000, month=1, day=1,hour=H[0], minute=M[0])
    d_end = datetime.datetime(year=2000, month=1, day=1,hour=H[1], minute=M[1])

    study_end = d_end - datetime.timedelta(minutes=K)

    ans = study_end - d_start
    print(ans.seconds // 60)
    return


# Generated by 1.1.7.1 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()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    solve(H, M, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;
// gcd: 最大公約数, lcm: 最小公倍数
template<typename T>
T euclidean(T a, T b){
    if(a < b) swap(a, b);
    T r = a % b;
    while(r != 0){
        a = b; b = r; r = a % b;
    }
    return b;
}
template<typename T>
T gcd(T a, T b){
    return euclidean(a, b);
}
template<typename T>
T lcm(T a, T b){
    T g = gcd(a, b);
    return a / g * b;
}

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

    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    if(n > m){
        swap(n, m);
        swap(s, t);
    }

    int num = gcd(n, m);
    int num2 = lcm(n, m);

    int a = num2/n, b = num2/m;

    bool flag = true;
    for(int i = 0LL; i <= num2; i += a*b){
        if(s[i/a] != t[i/b]) flag = false;
    }
    cout << (flag ? num2 : -1LL) << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
ans = 0
for k in range(1, N + 1):
    ans += ((N // k + 1) * k * (N // k)) // 2
print(ans)

Measured memory_bytes: 63500
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;
typedef long long ll;

const int N=100005;

map<ll,ll>g;
int q,n;
ll a[N],m,b[N]; 

void work(ll e){
	if(e>=m)return;
	ll t=0;
	while(g.size()){
		auto it=g.begin();
		if(-it->fi<=e)break;
		ll p=-it->fi,u=it->se;
		g.erase(it);t+=p/e*u;if(p%e)g[-p%e]+=u;
	}
	if(t)g[-e]+=t;m=e;
}

int main(){
	scanf("%d%d",&n,&q);a[0]=n;
	for(int i=1;i<=q;i++)scanf("%lld",&a[i]);
	m=a[q];g[-m]=1;
	for(int i=q-1;i>=0;i--)work(a[i]);
	for(auto p:g)b[1]+=p.se,b[-p.fi+1]-=p.se;
	for(int i=1;i<=n;i++)b[i]+=b[i-1],printf("%lld\n",b[i]);
	return 0;
}

Measured memory_bytes: 9344
N = gets.to_i
ary = gets.split(" ").map{|i| i.to_i}

i = 1
count = 0
ary.each do |num|
  if num == i
	count += 1
    i += 1
  end
end

if count == 0
  puts -1
else
  puts N - count
end

Measured memory_bytes: 15364
#include <stdio.h>

main(){
  int i, d, s;

  while(1){
    s=0;
    if(scanf("%d", &d)==EOF) break;
    for(i=1;(i*d)<600;i++){
      s+=d*d*d*i*i;
    }
    printf("%d\n", s);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int main() {
  int a,b;
  cin>>a>>b;
  string s;
  cin>>s;
  bool flag = true;
  frn(i,s.size()) {
    if(i == a) {
      if(s[i] != '-') flag = false;
    }
    else if(s[i]-'0' < 0 || s[i]-'0' > 9) {flag = false;}
  }
  if(flag) cout<<"Yes";
  else cout<<"No";
}

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

#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

void yes() {cout << "YES" << "\n";}
void no() {cout << "NO" << "\n";}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int red = 0, white = 0;
    for(int i=0; i<n; i++) {
        if(s[i] == 'W') white++;
        else red++;
    }
    int ans = 2e5 + 5;
    int a = 0, b = 0;
    for(int i=0; i<red; i++) {
        if(s[i] == 'W') a++;
    }
    for(int i=red; i<n; i++) {
        if(s[i] = 'R') b++;
    }
    ans = min(a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3764
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    a, b, h, m = list(map(int,sys.stdin.readline().split()))
    #bの角度
    a_rad = (h/12 + ((5 * m) / pow(60,2))) * 2 * math.pi
    b_rad = float(m/60) * 2 * math.pi
    #print(a_rad, b_rad)
    rad_a2b = min(2 * math.pi - abs(a_rad - b_rad), abs(a_rad - b_rad))
    #print(rad_a2b)
    c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(rad_a2b))
    print("{:.10f}".format(c))
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 9800
#include <iostream>
#include <vector>
#include <cstdlib>
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; i++) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5132
/**************************************************
* BISMILLAHIR RAHMANIR RAHIM
* Author Name  : SHOHAG (ICT'13)
* University   : ICT, MBSTU
 ***************************************************/
#include<bits/stdc++.h>
#define  pi    acos(-1.0)
#define  pb    push_back
#define  mp    make_pair
#define  ff     first
#define  ss     second
#define  all(x)   x.begin(),x.end()
#define MAX 100005
#define MIN -1
#define INF 1000000000
#define dbg cout<<"Executed"<<endl;
#define SET(array_name,value) memset(array_name,value,sizeof(array_name))
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll n,i,j,L,m,k,t,sum,cnt,d,rem,mod,v,r,l,row,extra,mx,mn,a[MAX];
string str,str2;
map<ll,ll>maap;
map<ll,ll>::iterator it;
vector<ll>vec,v2,v3;
vector<ll>v4[51];
/************************************ Code Start Here ******************************************************/
int bubble_sort(ll A[],ll n)
{
    int round,temp,i;
    for(round=1; round<n; round++)
    {
        for(i=0; i<n-round; i++)
            if(A[i]>A[i+1])
            {
                swap(A[i+1],A[i]);
                cnt++;
            }
    }
}

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

        bubble_sort(a,n);
        for(i=0;i<n-1;i++)
           cout<<a[i]<<' ';
           cout<<a[n-1]<<endl;
        cout<<cnt<<endl;


    return 0;

}



Measured memory_bytes: 3128
from typing import MutableSequence


def bubble_sort(a_list: MutableSequence, n:int) -> int:
    """バブルソート"""
    sw_cnt = 0
    for i in range(n - 1):
        for j in range(n -1, i, -1):
            if a_list[j - 1] > a_list[j]:
                a_list[j - 1], a_list[j] = a_list[j], a_list[j - 1]
                sw_cnt += 1

    print_list = [str(i) for i in a_list]
    print(' '.join(print_list))
    print(sw_cnt)

    
if __name__ == "__main__":
    n = int(input())
    input_list = [int(x) for x in input().split()]

    bubble_sort(input_list, n)


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

#define FST first
#define SCD second
#define MODP 1000000007

typedef long long LL;
typedef pair<int, int> PA;

int cmp(PA x, PA y) {
    return x.SCD < y.SCD;
}

int main() {
#ifdef FDB
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n, m, k;
    cin>>n>>m;
    if (n<m) {
        for (int i=0;i<m;++i) printf("%d", n);
    }
    else {
        for (int i=0;i<n;++i) printf("%d", m);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A, B, C, X;

    cin >> A >> B >> C >> X;

    int count = 0;

    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B ; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    count++;
                }
            }
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
 int n=RD();

    map<int, int> m;
     fr{
        int tmp=RD();
        m[tmp]++;
    }
    int cnt = 0;
    for(auto i : m) {
        if(i.second % 2 == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
 }




Measured memory_bytes: 4992
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int n, m;
	bool a[30][30];
	memset(a, 0, sizeof(a));

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int b;
			
			cin >> b;
			a[i][b - 1] = 1;
		}
	}

	int t = 0;

	for (int i = 0; i < m; i++) {
		bool g = 1;
		for (int j = 0; j < n; j++) {
			if (!a[j][i]) {
				g = 0;
				break;
			}
		}
		if (g)
			t++;
	}

	cout << t << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int east[n + 10];
    int c = 0;
    rep(i, n){
        if(s[i] == 'E') c++;
        east[i] = c;
    }
    int out = east[n - 1] + east[0];
    for(int i = 1; i < n; i++){
        out = min(out, i - east[i - 1] + east[n - 1] - east[i]);
    }
    cout << out << endl;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

const lld mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;

    lld ans = 0;

    for (lld i = k; i <= n + 1; i++) {
        lld mn = (i - 1) * i / 2;
        lld mx = (n + n - i + 1) * i / 2;
        ans += (mx - mn + 1);
        ans %= mod;
    }

    cout << ans << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Measured memory_bytes: 3652
#include <cstdio>
#include <math.h>
#include <utility>

using namespace std;

int main ()
{
  int H, W;
  int count = 0;
  pair<int, int> data[5000];

  while (1) {
    scanf("%d", &H);
    scanf("%d", &W);
    if (H == 0 && W == 0) {
      break;
    }
    data[count].first = H;
    data[count].second = W;
    count++;

  }

  for (int i = 0; i < count; i ++) {
    for (int j = 0; j < data[i].first; j++) {
      for (int k = 0; k < data[i].second; k++) {
        if ((j + k) % 2 == 0) {
          printf("#");
        } else {
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

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

int main(){
    int n,k,r,s,p;
    cin>>n>>k>>r>>s>>p;
    string t;
    cin>>t;
    bool lose[200010]={false};
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i<n-k){
            if(lose[i]) continue;
            if(t[i]==t[i+k]) lose[i+k]=true;
            if(t[i]=='r') ans+=p;
            else if(t[i]=='s') ans+=r;
            else ans+=s;
        }
        else{
            if(lose[i]) continue;
            if(t[i]=='r') ans+=p;
            else if(t[i]=='s') ans+=r;
            else ans+=s;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    string S;
    cin >> S;
    int Y = stol(S.substr(0,2));
    int M = stol(S.substr(2,2));
    if (M >= 1 && M <= 12) {
        if (Y >= 1 && Y <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "YYMM" << endl;
        }
    } else {
        if (Y >= 1 && Y <= 12) {
            cout << "MMYY" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

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

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var A = int.Parse(a.Split(' ')[0]);
            var B = int.Parse(a.Split(' ')[1]);

            if(A * B == 15){
                Console.WriteLine("*");
            }
            else if(A + B == 15){
                Console.WriteLine("+");
            }else{
                Console.WriteLine("x");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++)
		cin>>a[i];
	int ans=0;
	bool check=true;
	do{
		for (int i=0;i<n;i++)
			if (a[i]%2)
				check=false;
			else a[i]/=2;
		if (check)	ans++;
	}while(check);
	cout<<ans<<endl;
}

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

int n, k, a;
int dp[101][1000001];
int pr[101][1000001];

int main()
{
	cin >> n >> k;
	
	dp[0][0] = 1;
	for(int j = 0; j <= k; j++)
	pr[0][j] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		dp[i][0] = 1;
		pr[i][0] = 1;
		for(int j = 1; j <= k; j++)
		{
			dp[i][j] = pr[i - 1][j];
			if(j - a - 1 >= 0)
				dp[i][j] = (dp[i][j] - pr[i - 1][j - a - 1] + int(1e9 + 7)) % int(1e9 + 7);
			pr[i][j] = (pr[i][j - 1] + dp[i][j]) % int(1e9 + 7);
		}
	}
	
	cout << dp[n][k] << endl;
}


Measured memory_bytes: 494208
#include<cstdio>
const int MAXN = 100000;
int pre[MAXN + 5], f[MAXN + 5];
int Find(int x) {
	if( pre[x] == x ) return x;
	int ret = Find(pre[x]);
	f[x] = f[x] + f[pre[x]];
	return pre[x] = ret;
}
int main() {
	int N, M;
	bool flag = true;
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
		pre[i] = i;
	for(int i=1;i<=M;i++) {
		int L, R, D;
		scanf("%d%d%d",&L,&R,&D);
		if( flag ) {
			if( Find(L) == Find(R) ) {
				if( f[R] <= f[L] ) {
					int p = f[L] - f[R];
					if( p != D ) flag = false;
				}
				else {
					flag = false;
				}
			}
			else {
				int k = Find(L);
				pre[k] = L;f[k] = -f[L];
				pre[L] = R;f[L] = D;
			}
		}
	}
	if( flag ) printf("Yes\n");
	else printf("No\n");
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,m;
  cin>>n>>m;

  ll ans = 1ll;
  for(ll i=(m/n);i;--i){
    if((m-i*n)%i==0){
      ans = i;
      break;
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 384
import itertools 
N, X, Y = (int(i) for i in input().split())  

lis = range(N)
ans = [0] * (N-1)
for a, b in itertools.permutations(lis, 2):
  if a >= b:
    continue
  tmp = min(b-a, abs(X-a-1) + abs(Y-b-1) + 1)
  ans[tmp-1] += 1

for x in ans:
  print(x)

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



int main (){
  

  int W, H;
  cin>>W>>H;


  int x,y,r;
  cin>>x>>y>>r;
  

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
 cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
    }


  



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

using namespace std;

#define ll long long
#define pii pair<int,int>
#define mod 1000000007
int main()
{
    
    int s;
    cin>>s;
    int n =s;
    vector<vector<ll>> com(n+1,vector<ll>(n+1,1));
    for(int i=2;i<=n;i++)
    {
        for(int j =1;j<i;j++)
        {
            com[i][j] = (com[i-1][j] + com[i-1][j-1])%mod;
        }
    }
    int k = s/3;
    ll ans =0;
    for(int p=1;p<=k;p++)
    {
        ans = (ans + com[s-2*p-1][p-1])%mod; 
    }
    cout<<ans<<endl;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    string passw;
    cin >> passw;
    for (int i = 1; i < passw.length(); i++) {
        if (passw[i] == passw[i - 1]) {
            cout << "Bad" << "\n";
            return 0;
        }
    }
    cout << "Good" <<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;
 
const LL inf = 1e18L+7;
int main() {
    fastio
    int n,w;
    cin>>n>>w;
    int value[n+1],weight[n+1];
    
    LL tv = 0;
    rng(i,0,n){
        cin>>weight[i+1]>>value[i+1];
        tv += value[i+1];
    }
    vector<LL> dp(tv+1, inf);
    dp[0] = 0;
    rng(i,1,n+1){
        for(int curr_value = tv; curr_value-value[i]>=0 ; curr_value--){
            dp[curr_value] = min(dp[curr_value], dp[curr_value-value[i]] + weight[i]);
        }
    }
    LL ans = 0;
    rng(i,0,tv+1){
        if(dp[i]<=w)
            ans = i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> p(N);
	for (int i = 0; i < N; i++) cin >> p[i];

	auto v = p;
	sort(v.begin(), v.end());

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != v[i]) cnt++;
	}

	if (cnt == 2) cout << "YES" << endl;
	else if (cnt == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	ifstream fin("input.txt");
	int N;
	cin >> N;
	if (N / 10 == 9 || N % 10 == 9)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

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

using namespace std;
int n,a[100+5],x,y,h;
int main()
{
  scanf("%d",&n);
    for(int i=1;i<=n;i++)
  {
     scanf("%d",&a[i]);
     h+=a[i];
  }
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    printf("%d\n",h-a[x]+y);
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class P{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        List<string> w = new List<string>();
        for (int i = 0; i < n; i++)
            w.Add(Console.ReadLine());
        bool f = true;
        for (int i = 0; i < n - 1; i++)
            f = f && w[i][w[i].Length - 1] == w[i + 1][0];
        w.Sort();
        for (int i = 0; i < n - 1; i++)
            f = f && w[i] != w[i + 1];
        Console.WriteLine(f ? "Yes" : "No");
    }
}

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

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("yes\n")
#define no printf("no\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

string s;

void solve(){

    stack<int> st;
    rep(i, s.size()){
        if(s[i]=='('){
            st.push(0);
        }
        if(s[i]=='['){
            st.push(1);
        }
        if(s[i]==')'){
            if(st.empty() || st.top()!=0){
                no;
                return;
            }else{
                st.pop();
            }
        }
        if(s[i]==']'){
            if(st.empty() || st.top()!=1){
                no;
                return;
            }else{
                st.pop();
            }
        }
    }
    if(st.empty()) yes;
    else no;
}

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

    while(getline(cin,s),s!="."){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<bitset>
#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
#define _GLIBCXX_DEBUG

using namespace std;

ll choose2(ll n) {
    return n * (n - 1) / 2;
}
int main() {
    int a, b;
    cin >> a >> b;
    bool ans = false;
    for (int i = 0; i < 10000; i++) {
        if (i * 2 / 25 == a && i / 10 == b) {
            cout << i << endl;
            ans = true;
            break;
        }
    }
    if (ans == false) {
        cout << -1 << endl;
    }
}


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

int main() {
    string s;  cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int r, g, b;
	cin >> r >> g >> b;
	int a = 100*r + 10*g + b;
	if((a % 4) == 0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}



Measured memory_bytes: 3624
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, W, *WV = map(int, read().split())
    weight = WV[::2]
    value = WV[1::2]

    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        for sum_w in range(W + 1):
            if sum_w - weight[i] >= 0:
                dp[i + 1][sum_w] = dp[i][sum_w - weight[i]] + value[i]
            if dp[i + 1][sum_w] < dp[i][sum_w]:
                dp[i + 1][sum_w] = dp[i][sum_w]

    print(dp[N][W])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 120304
//https://atcoder.jp/contests/abc143/tasks/abc143_b
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> lis;
	lis.resize(n);
	ll i;
	for(i=0;i<n;i++)
	{
		cin>>lis[i];
	}
	vector <ll> slis;
	ll prod=0;
	for(i=0;i<n-1;i++)
	{
		ll j;
		for(j=i+1;j<n;j++)
		{
			prod=0;
			prod=lis[i]*lis[j];
			slis.push_back(prod);
		}
	}
	ll x;
	x=slis.size();
	ll sum=0;
	for(i=0;i<x;i++)
	{
		sum=sum+slis[i];
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 3688
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int i = x, count = 1;
    for(;; i += x){
      count++;
      if(i%360 == 0)
        break;
    }
    
    System.out.println(i/x);
  }
}


Measured memory_bytes: 35548
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());

        // 主処理
        long total = b - (a - 1);
        long countC = b / c - (a - 1) / c; // bまでの約数の数 - aまでの約数の数
        long countD = b / d - (a - 1) / d; // bまでの約数の数 - aまでの約数の数
        long cm = b / lcm((int) c, (int) d) - (a - 1) / lcm((int) c, (int) d); // aからbまでのcとdの公倍数の数
        long result = total - countC - countD + cm;

        // 出力
        System.out.println(result);
        sc.close();
    }

    public static long lcm(int a, int b) {
        int temp;
        long c = a;
        c *= b;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return c / b;
    }
}

Measured memory_bytes: 21460