akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vdewansa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int costPrev = Math.abs(h[1] - h[0]);
            int costPrevPrev = 0;
            for (int i = 2; i < N; i++) {
                int cost = Math.min(
                        costPrev + Math.abs(h[i] - h[i - 1]),
                        costPrevPrev + Math.abs(h[i] - h[i - 2]));
                costPrevPrev = costPrev;
                costPrev = cost;
            }
            out.println(costPrev);
        }

    }
}



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

namespace T1PBC
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int Rwhite = s.Count(x => x == '.');
            int RBlack = s.Count(x => x == '#');

            int LBlack = 0;

            int result = Rwhite + LBlack;
            for (int i = 0; i < input; i++)
            {
                if (s[i] == '.')
                {
                    Rwhite--;
                }
                else
                {
                    LBlack++;
                }

                if ((LBlack + Rwhite) < result)
                {
                    result = LBlack + Rwhite;
                }

            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int r;
    cin >> r;
    cout <<fixed << setprecision(10)<< 2.0L * PI * r; 
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3796
#以下模範解答
s = input()
# s_asc = ''.join(sorted(s))
s_asc = sorted(s)
t = input()
# t_desc = ''.join(sorted(t, reverse = True))
t_desc = sorted(t, reverse = True)

if s_asc < t_desc:
    print('Yes')
else:
    print('No')

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

struct NODE {
	int p,sta;
	NODE() {}
	NODE(int p,int sta):p(p),sta(sta) {}
};
const int maxn = 20;
bool k[maxn];
vector<NODE> A[maxn];

int main() {
	int n,m,MM = 0;
	scanf("%d",&n);
	int end = 1<<n;
	for(int i=1; i<=n; i++) {
		scanf("%d",&m);
		for(int j=1; j<=m; j++) {
			int a,b;
			scanf("%d%d",&a,&b);
			A[i].push_back({a,b});
		}
	}
	int tmp = 0,tmax;
	bool ok;
	for(int i=0; i<end; i++) {
		tmp = i;
		tmax = 0;
		ok = 1;
		for(int j=1; j<=n; j++) {
			k[j] = tmp%2;
			tmax+=k[j];
			tmp/=2;
		}
		if(tmax <= MM) continue;
		//cout << "-------------\n";
		for(int j=1; j<=n; j++) {
			if(k[j]) for(NODE now: A[j]) {
				//cout <<now.p << " "<< now.sta << endl;
				if(k[now.p] != now.sta) {
					ok = 0;
					break;
				}
			}
			if(!ok) break;
		}
		if(ok) {
			//for(int j=1; j<=n; j++) printf("%d%c",k[j]," \n"[j==n]);
			MM = max(MM,tmax);
		}
	}
	printf("%d\n",MM);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> p(n);
    rep(i, n)   cin >> p[i], p[i]--;
    vector<ll> dp(n+1, 0);
    ll res=0;
    rep(i, n){
        dp[p[i]+1] = dp[p[i]]+1;
        res = max(res, dp[p[i]+1]);
    }
    
    cout << n-res << endl;
}


Measured memory_bytes: 6404
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]

x = list(map(int, input().split()))

if x[0] in a and x[1] in a:
	print("Yes")
elif x[0] in b and x[1] in b:
	print("Yes")
elif x[0] == 2 and x[1] == 2:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

int main() {
    vector<vector<int> > shape;
    for(string line; getline(cin, line); ) {
        for(char& c : line) if(c == ',') c = ' ';
        istringstream iss(line);
        vector<int> nums;
        for(int num; iss >> num; nums.push_back(num)) ;
        shape.push_back(nums);
    }

    vector<vector<int> > dp;
    for(const auto& vec : shape) {
        dp.push_back(vector<int>(vec.size(), 0));
    }

    dp[0][0] = shape[0][0];

    for(int i = 0; i < (int)shape.size() - 1; i++) {
        for(int j = 0; j < (int)shape[i].size(); j++) {
            int l, r;
            if(shape[i].size() < shape[i + 1].size()) {
                l = j, r = j + 1;
            }
            else {
                l = j - 1, r = j;
            }

            if(0 <= l) {
                dp[i+1][l] = max(dp[i+1][l], dp[i][j] + shape[i+1][l]);
            }

            if(r < (int)shape[i+1].size()) {
                dp[i+1][r] = max(dp[i+1][r], dp[i][j] + shape[i+1][r]);
            }
        }
    }

    cout << *dp.rbegin()->begin() << endl;
}

Measured memory_bytes: 1272
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        Set<Integer> num=new HashSet<>();
        for(int i=0;i<N;i++){
            int di=sc.nextInt();
            num.add(di);
        } 
        System.out.println(num.size());
    }
}

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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> vec(n);
    for(int i=0;i<q;i++){
        int win;
        cin >> win;
        vec.at(win-1)++;
    }
    for(int i=0;i<n;i++){
        if(vec.at(i)+k-q > 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld dp[302][302][302];
int main()
{
	int n,x;
	cin>>n;
	int one=0, two=0,three=0;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		if(x==1)one++;
		if(x==2)two++;
		if(x==3)three++;
		
	}
	//cout<<one<<" "<<two<<" "<<three<<"\n";
	
	
	
	for(int k=0;k<=n;k++)
	for(int j=0;j<=n;j++)
	for(int i=0;i<=n;i++)
	{	
		
		if((i+j+k)==0){dp[i][j][k]=0;continue;}
		
		int sum=i+j+k;
		dp[i][j][k]+=((double)n/sum);
		if(i-1>=0)dp[i][j][k]+=dp[i-1][j][k]*i /sum;
		if(j-1>=0)dp[i][j][k]+=dp[i+1][j-1][k]*j /sum;
		if(k-1>=0)dp[i][j][k]+=dp[i][j+1][k-1]*k /sum;
		
	}
	cout<<fixed<<setprecision(10)<<dp[one][two][three];
	//cout<<"hh";
	
	
}

Measured memory_bytes: 430336
a, b, m = map(int, input().split())
lista = list(map(int, input().split()))
listb = list(map(int, input().split()))

ans = min(lista)+min(listb)

for i in range(m):
    x, y, c = map(int, input().split())
    dprice = lista[x-1]+listb[y-1] - c
    if ans > dprice:
        ans = dprice

print(ans)


Measured memory_bytes: 18612
import re
n = int(input())
s = []
compiled = re.compile(r"AB")

pre = 0
xa=0
bx=0
ba=0
for i in range(n):
    one = input()
    pre+=len(compiled.findall(one))
    f=one[0]
    l=one[-1]


    if f=="B" and l=="A":
        ba+=1
    elif f=="B" and l!="A":
        bx+=1
    elif f!="B" and l=="A":
        xa+=1

#print(ba,bx,xa,pre)
cnt=0
if ba>=1:
    cnt+=ba-1
    if xa>=1:
        xa-=1
        cnt+=1
    
    if bx>=1:
        bx-=1
        cnt+=1

cnt += xa if xa<bx else bx
print(cnt+pre)



Measured memory_bytes: 3316
import java.util.*
import java.math.*

fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    val mod = 1000000007L
    val dp = LongArray(N+1)
    var a = if (M--  > 0) readLine()!!.toInt() else 0
    dp[0] = 1
    dp[1] = if (a == 1) {if (M-- > 0) a = readLine()!!.toInt();0} else 1

    for (n in 2 .. N) {
        if (n == a) {
            if (M-- > 0)
                a = readLine()!!.toInt()
            continue
        }
        dp[n] = (dp[n-1] + dp[n-2]) % mod
    }

    println(dp[N])

//    println("%.9f".format(ans))
}


Measured memory_bytes: 41176
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d;
  	cin>> a >> b >> c >> d;
  	int left=a+b;
  	int right=c+d;
  	if(left>right)
    {
    	cout<<"Left"<<endl;
    }else if(left<right)
    {
    	cout<<"Right"<<endl;
    }else{
    	cout<<"Balanced"<<endl;
    }
}

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

typedef long long int llint;

string s, t;

int main()
{
  cin>> s >> t;

  map<char, char> m, mm;

  bool flg = true;

  for(int i = 0; i < s.size(); i++) {

    if(!m[s[i]]) {
      m[s[i]] = t[i];
    } else {
      if(m[s[i]] != t[i]) flg = false;
    }

    if(!mm[t[i]]) {
      mm[t[i]] = s[i];
    } else {
      if(mm[t[i]] != s[i]) flg = false;
    }
    
  }
  
  cout<< (flg ? "Yes" : "No" ) <<endl;

  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long
#define M 1000
using namespace std;  
#define PI 3.141592653589793238462643383279502884197169
int main()
{ int k;
 cin>>k;
   
 string s;
  cin>>s;
  if(s.size()<=k)
    cout<<s;
 else {
   for(int i=0;i<k;++i)
     cout<<s[i];
   cout<<"...";
 }

    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;

namespace Program{
  class program{
    static void Main(){
      int N = int.Parse(Console.ReadLine());
      int[] Cost = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
      
      int[] MinCost = new int[N];
      MinCost[0] = 0;
      MinCost[1] = Math.Abs(Cost[0]-Cost[1]);
      for(int i=2;i<N;i++)
        MinCost[i] = Math.Min(MinCost[i-1] + Math.Abs(Cost[i]-Cost[i-1]),MinCost[i-2] + Math.Abs(Cost[i]-Cost[i-2]));
      
      Console.WriteLine(MinCost[N-1]);
    }
  }
}

Measured memory_bytes: 18016
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};

function main(input) {
  const o = new I(input);

  var n = o.a();
  var h = o.l();

  var cur = 0;
  var count = 0;
  for(var i=0; i < h.length; i++) {
    if (h[i] >= cur) {
      cur = h[i];
      count += 1;
    }
  }
  console.log(count);
}


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


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

using V = int;
using W = long long;
struct Edge {V from, to; W weight;};

vector<W> Dijkstra(const auto& G, auto s) {
  using Node = tuple<W, V>;
  priority_queue<Node, vector<Node>, greater<Node>> q;
  vector<W> d(G.size(), -1);
  q.emplace(0, s);
  while(!q.empty()) {
    W cost; V cur;
    tie(cost, cur) = q.top();
    q.pop();
    if(~d[cur]) continue;
    d[cur] = cost;
    for(auto& e: G[cur]) if(!~d[e.to]) q.emplace(cost + e.weight, e.to);
  }
  return d;
}

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<vector<Edge>> G(N);
  W d = 0;
  for(int i = 0; i < M; ++i) {
    int A, B, D;
    cin >> A >> B >> D;
    --A, --B;
    G[A].push_back({A, B, D});
    G[B].push_back({B, A, D});
    d += D;
  }

  auto D = Dijkstra(G, 0);

  vector<V> order(N);
  iota(begin(order), end(order), 0);
  sort(begin(order), end(order), [&](auto l, auto r) {return D[l] < D[r];});

  W ans = LLONG_MAX;
  vector<bool> visited(N, false);
  for(auto v: order) {
    visited[v] = true;
    for(auto e: G[v]) if(visited[e.to]) d -= e.weight;
    ans = min(ans, D[v] * C + d);
  }
  cout << ans << endl;
}

Measured memory_bytes: 18304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp106 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var ans = new long[N];

            if (N % 2 == 0) {
                int k = N / 2;
                for (int i = 0; i < N; i++) {
                    if (i <= k - 1) {
                        ans[i] = a[-2 * i + 2 * k - 1];
                    } else {
                        ans[i] = a[2 * (i - k)];
                    }
                }
            } else {
                int k = N / 2;
                for (int i = 0; i < N; i++) {
                    if (i <= k - 1) {
                        ans[i] = a[-2 * i + 2 * k];

                    } else if (i == k) {
                        ans[i] = a[0];
                    } else {
                        ans[i] = a[2 * (i - k) - 1];
                    }
                }


            }

            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 48056
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int N;
    string s;
    cin>>N;
    cin>>s;
    for(int i=0;i<s.length();i++){
        s[i]+=N;
        if(s[i]>'Z'){
            s[i]-='Z';
            s[i]+='A';
            s[i]--;
        }
    }
    cout<<s;
}


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

#define nl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define Flash ios_base::sync_with_stdio(0),cin.tie(0),cout.tie()

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;

const llong INF = 1e18;
const llong MOD = 1e9 + 7;
const int MXN = 1e5 + 5;

using namespace std;

llong a, b, c, cnt;

int main(){
    Flash;
    cin >> a >> b >> c;
    while(!(a % 2) && !(b % 2) && !(c % 2)){
        if(a == b && b == c) return cout << -1, 0;
        cnt ++;
        int a1 = b / 2 + c / 2;
        int b1 = a / 2 + c / 2;
        int c1 = a / 2 + b / 2;
        a = 0, b = 0, c = 0;
        a = a1, b = b1, c = c1;
    }
    cout << cnt;
    return 0;
}


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

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int A, B;
  cin >> A >> B;

  int answer {A+B};
  maxs(answer, A-B);
  maxs(answer, A*B);
  cout << answer << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
#define nl cout<<"\n"
//cout<<fixed<<setprecision(11);
const ll MOD=1e9+7;
const ll ARR_MAX = 1e5+1;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

void solve(){
    int k,x;cin>>k>>x;
    if(500*k>=x){
        cout<<"Yes",nl;
    }
    else{
        cout<<"No",nl;
    }
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]={0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]={-1, 1, 0, 0, -1, 1, -1, 1};
const LL mod=1e9+7;
LL quick_mod(LL a,LL n)
{
    LL ret=1;
    while(n)
    {
        if(n&1)
            ret=ret*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ret;
}
int num[100005];
int main()
{
    //freopen("D:\\chnegxubianji\\inORout\\in.txt", "r", stdin);
    //freopen("D:\\chnegxubianji\\inORout\\out.txt", "w", stdout);
    LL n;
    scanf("%lld",&n);
    for(int i=1; i<=n; i++)
    {
        LL tem;
        scanf("%d",&tem);
        num[tem]++;
    }
    if(n%2==1)
    {
        int flag=1;
        for(int i=n-1;i>0;i-=2)
        {
            if(num[i]!=2)
            {
                flag=0;
                break;
            }
        }
        if(num[0]!=1)
            flag=0;
        if(!flag)
            printf("0\n");
        else
            printf("%lld\n",quick_mod(2,n/2));
    }
    else
    {
        int flag=1;
        for(int i=n-1;i>0;i-=2)
        {
            if(num[i]!=2)
            {
                flag=0;
                break;
            }
        }
        if(!flag)
            printf("0\n");
        else
            printf("%lld\n",quick_mod(2,n/2));
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
 
string s;
 
int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	set<char> st;
	bool ok = true;
	FOR(i, s.size()) {
		if (st.count(s[i])) ok = false;
		st.insert(s[i]);
	}
	cout << (ok ? "yes" : "no") << endl;
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();

		n=n%26;

		char[] ss=new char[s.length()];
		for(int i=0;i<s.length();i++) {
			ss[i]=s.charAt(i);
			for(int j=0;j<n;j++) {
			    ss[i]++;
			    if(String.valueOf(ss[i]).matches("[^A-Z]")) {
			    	ss[i]='A';
			    }
			}

		}
		for(int i=0;i<s.length();i++) {
			System.out.print(ss[i]);
		}System.out.println();


	}

}


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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ft first
#define sd second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

LL jc[15],l;

//LL g[14][14*9+1]
char s[23];
map<LL,LL>f[14][14*9+1][3];

map<LL,LL>::iterator it;

void init(){
     rep(i,0,l-1){
        rep(j,0,9*(i+2)){
            rep(now,0,3){
                f[i][j][now].clear();
                }
            }
        }
    //jc[0]=1;rep(i,0,15)jc[i]=jc[i-1]*i;
    rep(i,0,s[0]-'0')f[0][i][0][i+1]=1;
    f[0][s[0]-'0'][1][s[0]-'0'+1]=1;

    rep(i,0,10)f[0][i][2][i+1]=1;

   // cout<<f[0][0][1][1]<<endl;
    rep(i,0,l-1){
        rep(j,0,9*(i+2)){
            rep(now,0,3){//cout<<i<<' '<<j<<' '<<now<<endl;
            for(it=f[i][j][now].begin();it!=f[i][j][now].end();++it){
                //cout<<i<<' '<<j<<' '<<now<<endl;
                LL p=(*it).ft,v=(*it).sd;
                int nxt=0,nn=s[i+1]-'0';
                if(now!=2)rep(k,0,10){
                    if(now==1 && k==nn)nxt=1;
                    if(now==1 && k>nn)break;
                    f[i+1][j+k][nxt][p*(k+1)]+=v;
                }else{
                    rep(k,0,10){
                        f[i+1][j+k][2][p*(k+1)]+=v;
                    }
                }
            }
        }
    }
}
}


int main(){
    while(~scanf("%s",s)){
        LL ans=0,sum=0,pro=1,num=0;
        l=strlen(s);init();rep(i,0,l){
            sum+=s[i]-'0';
            pro*=(s[i]-'0')+1;
            num*=10;
            num+=s[i]-'0';
        }
     //   cout<<sum<<' '<<pro<<' '<<num<<endl;
       rep(i,0,sum){
            for(it=f[l-1][i][2].begin();it!=f[l-1][i][2].end();++it){
                ans+=(*it).sd;
            }
        }
        for(it=f[l-1][sum][2].begin();it!=f[l-1][sum][2].end();++it){
            if((*it).ft<pro)ans+=(*it).sd;
        }
        ans+=f[l-1][sum][0][pro];
        cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 75708
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x, y = map(int,input().split())
mod = 10**9 + 7
a = abs(x-y)
b = min(x,y) - a
if b%3 != 0:
    print(0)
    exit()
    
print(int(cmb(a+b//3+b//3, b//3, mod)))

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

int main(void){
    int n,m;
	long cost[100000];
	long max_cost;
	long long ans_cost=0;
	std::priority_queue<long> q;
    cin >> n;
	cin >> m;
	
	// 入力
	for(int i=0;i<n;i++){
		cin >> cost[i];
	}

	// 優先度付きキューに格納する
	for(int i=0;i<n;i++){
		q.push(cost[i]);
	}

	// 割引処理をM回実施する
	for(int i=0;i<m;i++){
		max_cost = q.top();
		q.pop();
		max_cost = max_cost / 2;
		q.push(max_cost);
	}

	// qの値を合計する
	for(int i=0;i<n;i++){
		ans_cost = ans_cost + q.top();
		q.pop();
	}
	cout << ans_cost << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int left(int i){return 2*i+1;}

int right(int i){return 2*i+2;}

int parent(int i){return (i-1)/2;}

void maxHeapify(vector<int> &vec,int i){
    int size=vec.size();
    int l= left(i);
    int r= right(i);
    int largest;
    //左の子，自分，右の子で最大のノードを選ぶ
    if(l<size&&vec[l]>vec[i])largest=l;
    else largest=i;
    if(r<size&&vec[r]>vec[largest])largest=r;
    //largestとiが異なる場合交換
    if(largest!=i){
        swap(vec[i],vec[largest]);
        maxHeapify(vec,largest);
    }
}

void buildMaxHeap(vector<int> &vec){
    //vec.size()/2-1は子を持つ最大の節点
    for(int i=vec.size()/2-1;i>=0;i--){
        maxHeapify(vec,i);
    }
}

void insert(vector<int> &vec,int key){
    vec.push_back(key);
    int h=vec.size()-1;
    while(h>0&&vec[parent(h)]<vec[h]){
        swap(vec[parent(h)],vec[h]);
        h=parent(h);
    }
}

int HeapExtractMax(vector<int> &vec){
    int h=vec.size()-1;
    int max=vec[0];
    swap(vec[0],vec[h]);
    vec.erase(vec.begin()+h);
    maxHeapify(vec,0);
    return max;
}

int main(){
    vector<int> vec;
    int x;
    char s[10];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='e'){
            if(s[1]=='n')break;
            else{
                out(HeapExtractMax(vec));
            }
        }else{
            in(x);
            insert(vec,x);
        }
    }
}


Measured memory_bytes: 7012
import collections

n=int(input())
As=list(map(int,input().split()))
ls=collections.Counter(As)
subd={}
an=ls.values()
ans=0
for k in an:
  ans+=k*(k-1)//2
sans=ans

for i in As:
  ans=sans+1-ls[i]
  print(ans)

Measured memory_bytes: 26780
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')
move = [(0, 1), (1, 1), (-1, 1), (0, -1), (1, -1), (-1, -1), (1, 0), (-1, 0)]
#A
def A():
    a, b, c = LI()
    if a == b:
        print(c)
    if b == c:
        print(a)
    if a == c:
        print(b)
    return

#B
def B():
    h, w = LI()
    s = SR(h)
    for y in range(h):
        for x in range(w):
            if s[y][x] == ".":
                b = 0
                for my, mx in move:
                    ym = my + y
                    xm = mx + x
                    if 0 <= ym < h and 0 <= xm < w:
                        if s[ym][xm] == "#":
                            b += 1
                s[y][x] = b
    for i in range(h):
        print("".join(map(str, s[i])))
    return

#C
def C():
    n, m = LI()
    edg = [[] for i in range(n)]
    ab = LIR_(m)
    for a,b in ab:
        edg[a].append(b)
        edg[b].append(a)
    ans = 0
    for a, b in ab:
        c = [True] * n
        ed = defaultdict(int)
        q = deque()
        q.append(0)
        c[0] = False
        ed[(a,b)] = True
        while q:
            now = q.pop()
            for e in edg[now]:
                if ed[(now,e)] or ed[(e,now)]:
                    continue
                ed[(now, e)] = True
                c[e] = False
                q.appendleft(e)
        if True in c:
            ans += 1
    print(ans)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 42480
#include<bits/stdc++.h>
using namespace std;
void solve(){
    string a;
    cin>>a;
    int n=a.size(),cnt=0;
    for(int i=0;i<n;++i){
        if(a[i]!=a[n-1-i])
            ++cnt;
    }
    cout<<cnt/2<<endl;
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int []output=new int[10000];
            int output_count=0;
            int input_count=0;
            int []input_casher=new int[10];
            string str = Console.ReadLine();
            do
            {
                if (str == "0")
                {
                    output[output_count] = input_casher[input_count - 1];
                    input_count--;
                    output_count++;
                }
                else
                {
                    input_casher[input_count] = int.Parse(str);
                    input_count++;
                }
                str = Console.ReadLine();
            } while (String.IsNullOrEmpty(str) == false);
            for (int n = 0; n < output_count; n++)
                Console.WriteLine(output[n]);
        }
    }
}

Measured memory_bytes: 5632
/* author   : mpily :-()
title : Competing.cpp
time :Sat Jan  4 10:36:59 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,K,R,S,P;
	cin>>N>>K;
	cin>>R>>S>>P;
	string T;
	cin>>T;
	vector<char>arr(N);
	int count = 0;
	for(int i = 0; i < N; i++){
		if(T[i] == 'r'){
			if(i < K){
				arr[i] = 'p';
				count+=P;
			}
			else if(arr[i-K] != 'p'){
				arr[i] = 'p';
				count +=P;
			}
			else{
				arr[i] = 'd';
			}
		}
		if(T[i] == 'p'){
			if(i < K){
				arr[i] = 's';
				count+=S;
			}
			else if(arr[i-K] != 's'){
				arr[i] = 's';
				count +=S;
			}
			else{
				arr[i] = 'd';
			}
		}
		if(T[i] == 's'){
			if(i < K){
				arr[i] = 'r';
				count+=R;
			}
			else if(arr[i-K] != 'r'){
				arr[i] = 'r';
				count +=R;
			}
			else{
				arr[i] = 'd';
			}
		}
	}
	cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int inf = 1e9;
vector<int> dx = {1, -1, 1, -1};
vector<int> dy = {1, 1, -1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  vector<P> b;
  bool board[h][w];
  for (auto&& w : a) cin >> w;
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') b.push_back(make_pair(i, j));
    }
  }

  int num = b.size();
  if (num == h * w) {
    cout << 0 << endl;
    return 0;
  }
  for (int ans = 1; ans < h + w; ans++) {
    for (int i = 0; i <= ans; i++) {
      int j = ans - i;

      for (auto&& v : b) {
        for (int k = 0; k < 4; k++) {
          int i0;
          int j0;
          i0 = v.first + dx[k] * i;
          j0 = v.second + dy[k] * j;
          if (i0 >= 0 && j0 >= 0 && i0 < h && j0 < w && a[i0][j0] == '.') {
            num++;
            a[i0][j0] = '#';
          }
        }
      }
    }
    if (num == h * w) {
      cout << ans << endl;
      return 0;
    }
  }
}

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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, x;
int a[100];

void init()
{
	cin >> N >> x;
	rep(i, N) cin >> a[i];
	sort(a, a+N);
}

void solve()
{
	int sum = 0;
	int res = 0;
	rep(i, N) {
		sum += a[i];
		if (sum <= x) res++;
		else break;
	}
	if (res == N && sum < x) res--;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    Cins(int, n, x);
    Cins(int, m, y);
    
    ll lx = 0, ly = 0;
    For(i, n-1){
        lx += ((ll)(i+1) * (n-1-i) % MOD) * ((x[i+1]-x[i]) % MOD) % MOD;
        lx %= MOD;
    }
    For(j, m-1){
        ly += ((ll)(j+1) * (m-1-j) % MOD) * ((y[j+1]-y[j]) % MOD) % MOD;
        ly %= MOD;
    }
    Cout(lx * ly % MOD);
}


Measured memory_bytes: 1024
function char(s, n)
  return s:sub(n, n)
end

n=io.read("*n", "*l")
s=io.read(n)

ans=1
for i=1,n-1 do
  if char(s,i)~=char(s,i+1) then
    ans=ans+1
  end
end

print(ans)

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    string ans = "second";
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            ans = "first";
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<vector>
#include<iostream>
#include<string>
#include<cmath>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
#define Cout(s) cout<<(s)<<endl;
using ll = long long;

using namespace std;

int main() {
	int A, B , C , D;
	cin >> A >> B >> C >> D;
	while (true) {
		C -= B;
		if (C <= 0) {
			Cout("Yes");
			break;
		}
		A -= D;
		if (A <= 0) {
			Cout("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    int n, m;
    cin >> n >> m;
    vector<string> as(n);
    vector<string> bs(m);
    rep(i, n)
    {
        cin >> as[i];
    }
    rep(i, m)
    {
        cin >> bs[i];
    }
    rep(i, n - m + 1)
    {
        rep(j, n - m + 1)
        {
            bool f = true;
            rep(k, m)
            {
                rep(l, m)
                {
                    if (as[i + k][j + l] != bs[k][l])
                    {
                        f = false;
                        break;
                    }
                }
            }
            if (f)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
    char c;
    cin >> c;

    if(isupper(c)){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int p=0;
    while(a>0&&c>0)
    {
        if(p==0)
        {
            c-=b;
            p=1;
        }
        else
        {
            a-=d;
            p=0;
        }
    }
    if(c<=0)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3132
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}


int main(){
  string s;
  cin >> s;
  bool c = false;
  bool f = false;
  rep(i,s.length()){
    if(!c){
      if(s[i] == 'C'){
        c = true;
      }
    }else{
      if(s[i] == 'F'){
        f = true;
        break;
      }
    }
  }
  if(f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a>0){cout<<"Positive"<<endl;return 0;}
    else if(a<=0&&0<=b){cout<<"Zero"<<endl;return 0;}
    else if(((b-a)%2)==0){cout<<"Negative"<<endl;return 0;}
    else{cout<<"Positive"<<endl;return 0;}
}

Measured memory_bytes: 384
N = int(input())
a_list = list(map(int, input().split()))

input_map = {i: 0 for i in range(10**5+1)}
for a in a_list:
    input_map[a] += 1


max_num = 0
for i in range(1, 10**5):
    max_num = max(input_map[i-1] + input_map[i] + input_map[i+1], max_num)
print(max_num)

Measured memory_bytes: 19700
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisect(l,r,f,discrete=True,left=True):
    """
    l,r: l<r int if discrete else float
    f: function defined on [l,...,r] to {False,True}
    if discrete: f defined on Z; else: R
    if left: f satisfies that there uniquely exists d such that iff i<=d then f(i)
    else: iff i>=d then f(i) is True
    return d such as those above
    """
    assert r>l
    if discrete: assert isinstance(l,int) and isinstance(r,int)
    eps=1 if discrete else 10**-12
    if (not left)^f(r): return r if left else r+1
    elif left^f(l): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if (not left)^f(h): l=h
        else: r=h
    return h if not discrete else l if left else r

class RollingHash(object):
    """
    construct: O(N)
    get_hash: O(1)
    LCP: O(logN)
    """
    def __init__(self,S,m1=10**9+9,b1=1007,m2=10**9+7,b2=1009):
        """
        S: string
        m1>m2: prime sufficiently large
        b1,b2: base 0<bi<mi
        """
        assert m1>m2 and 0<b1<m1 and 0<b2<m2
        n=len(S)
        self.__n=n
        self.__m1=m1
        self.__m2=m2
        self.__H1,self.__H2=[0]*(n+1),[0]*(n+1)
        self.__P1,self.__P2=[1]*(n+1),[1]*(n+1)
        for i,s in enumerate(S):
            self.__H1[i+1]=(self.__H1[i]*b1+ord(s))%m1
            self.__H2[i+1]=(self.__H2[i]*b2+ord(s))%m2
            self.__P1[i+1]=self.__P1[i]*b1%m1
            self.__P2[i+1]=self.__P2[i]*b2%m2

    @property
    def len(self):
        return self.__n

    def hash(self,l,r=None):
        """
        l,r: int (0<=l<=r<=n)
        return (hash1,hash2) of S[l:r]
        """
        if r is None: r=self.len
        assert 0<=l<=r<=self.len
        return ((self.__H1[r]-self.__P1[r-l]*self.__H1[l]%self.__m1)%self.__m1,
        (self.__H2[r]-self.__P2[r-l]*self.__H2[l]%self.__m2)%self.__m2)

    def LCP(self,l1,r1=None,rh2=None,l2=0,r2=None):
        if r1 is None: r1=self.len
        if rh2 is None: rh2=self
        if r2 is None: r2=rh2.len
        assert 0<=l1<=r1<=self.len and 0<=l2<=r2<=rh2.len
        L=0
        R=min(r1-l1,r2-l2)
        if self.hash(l1,l1+R)==rh2.hash(l2,l2+R): return R
        while(R-L>1):
            H=(L+R)//2
            if self.hash(l1,l1+H)==rh2.hash(l2,l2+H): L=H
            else: R=H
        return L

def resolve():
    n=int(input())
    S=input()
    # d=0ではtrue,d=nではfalseなので、そこでbisectする
    rh=RollingHash(S)
    def judge(d):
        # initialize
        J={rh.hash(i,i+d):-1 for i in range(n-d+1)}
        for i in range(n-d+1):
            h=rh.hash(i,i+d)
            if J[h]!=-1:
                if i-J[h]>=d: return True
            else: J[h]=i
        return False
    print(bisect(0,n,judge))
resolve()

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

int main(){
  int R,G,B,n; cin>>R >>G >>B >>n;
  int ans=0;
  for(int r=0;r<=3000;r++){
    for(int g=0;g<=3000;g++){
      int b=r*R+g*G;
      if(n>=b && (n-b)%B==0)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int count = 0;
		int i = 100;
		while(count < k) {
			if(a%i == 0 && b%i == 0) {
				count++;
			}
			i--;
		}
		System.out.println(i+1);
		sc.close();
	}
}


Measured memory_bytes: 23892
#include <iostream>
using namespace std;
int main() {
    int N;
    while(cin >> N, N!=0){
        int ans=0;
        for(int i=1; i<N; i++){
            int sum =0;
            for(int j=i; j<N; j++){
                sum += j;
                if(sum == N)ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160