akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, ans = 0, count = 0;
	cin >> N;
	vector<ll> data(N);
	FOR(i, 0, N) cin >> data.at(i);
	FOR(i,0,N-1){
		if(data.at(i)>=data.at(i+1)){
			count++;
			ans = max(ans, count);
		}
		else{
			count = 0;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3976
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)





int main()
{
	int N, M;
	cin >> N >> M;
	//N ひとのかず

	//M　ことばの数
	vector<vector<int>> tate(N + 1, vector<int>());
	vector<vector<int>> yoko(M + 1, vector<int>());
	REP(i, N) {
		int a;
		cin >> a;
		REP(j, a) {
			int b;
			cin >> b;
			tate[i + 1].push_back(b);
			yoko[b].push_back(i + 1);
		}
	}
	//true なら tate
	queue<pair<bool, int>> q;
	pair<bool, int> nanka;
	nanka.first = true;
	nanka.second = 1;
	q.push(nanka);

	vector<bool> tateEnd(N + 1, false);
	int tateEndNum = 0;
	vector<bool> yokoEnd(M + 1, false);

	bool flag = false;
	while (q.size() >= 1) {
		pair<bool, int> gomi = q.front();
		q.pop();
		if (gomi.first == true && tateEnd[gomi.second] == false) {
			tateEnd[gomi.second] = true;
			tateEndNum++;
			REP(i, tate[gomi.second].size()) {
				pair<bool, int> hoge;
				hoge.first = false;
				hoge.second = tate[gomi.second][i];
				q.push(hoge);
			}
		}
		else
			if (gomi.first == false && yokoEnd[gomi.second] == false) {
				yokoEnd[gomi.second] = true;
				REP(i, yoko[gomi.second].size()) {
					pair<bool, int> hoge;
					hoge.first = true;
					hoge.second = yoko[gomi.second][i];
					q.push(hoge);
				}
			}
		if (tateEndNum == N) {
			flag = true;
			break;
		}
	}
	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}
}

Measured memory_bytes: 9336
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll a;
    cin >> a ;
    cout << a + a*a + a*a*a <<endl;

}

Measured memory_bytes: 3156
import sys
from collections import defaultdict
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    n,k,l = map(int,input().split())
    Road = [list(map(int,input().split())) for i in range(k)]
    Train = [list(map(int,input().split())) for i in range(l)]

    uf_r = UnionFind(n)
    uf_t = UnionFind(n)

    for i in range(k):
        uf_r.union(Road[i][0]-1,Road[i][1]-1)

    for i in range(l):
        uf_t.union(Train[i][0]-1,Train[i][1]-1)

    Roots_dict = defaultdict(int)
    Roots = []
    for i in range(n):
        Roots.append((uf_r.find(i),uf_t.find(i)))
        Roots_dict[Roots[i]] += 1

    ans = [0]*n

    for i in range(n):
        ans[i] = Roots_dict[Roots[i]]

    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 126088
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

lli a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a >> b;
	lli res = (a * b) / __gcd(a, b);
	cout << res << '\n';
}

Measured memory_bytes: 256
N,M=map(int,input().split())
la=list(map(int,input().split()))
lcb=[]
for i in range(M):
    b,c=map(int,input().split())
    lcb.append([c,b])
la.sort()
lcb.sort()
tmpi=M-1
count=0
for i in range(N):
    if la[i]<lcb[tmpi][0]:
        la[i]=lcb[tmpi][0]
        count+=1
        #print(i,count)
        if count==lcb[tmpi][1]:
            #print(count)
            if tmpi==0:
                break
            tmpi-=1
            count=0

print(sum(la))


Measured memory_bytes: 23992
N = int(input())
a = list(map(int, input().split()))

X = sum(a)
b = [a[0]]
for i in range(1, N - 1):
    b.append(b[i-1] + a[i])

ans = []
for i in range(0, N - 1):
    ans.append(abs(X - 2*b[i]))

print(min(ans))


Measured memory_bytes: 27832
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a,b; cin >> a >> b;
	vector<int> v;
	rep(i,1000){
		if (i*i>100000) break;
		v.push_back(i*i);
	}
	rep(i,v.size()){
		if (v[i] == a*(int)pow(10,to_string(b).size()) + b){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    for g in range(n-m+1):
        d=[]
        for l in range(m):
            d.append(a[l+i][g:g+m])
        if d==b:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3060
mod=10**9+7
n=int(input())
l=list(map(int,input().split()))
s=[]
for i in range(n):
    if i==0:
        s.append(l[i])
    else:
        s.append(s[-1]+l[i])
ans=0
for i in range(n):
    ans=(ans+l[i]*(s[-1]-s[i]))%mod
print(ans%mod)

Measured memory_bytes: 31428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long n)
{

    ll num = n;
    ll ans = abs(n - 1);

    ll tmp = 1;
    for (ll i = 1; i * i <= n; i++)
    {
        if (num % i == 0)
        {
            ans = min(ans, abs(i - 1 + (num / i) - 1));
        }
    }

    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    string s[n];
    rep(i,n){
        cin >> s[i];
    }
    map<string, int> mp;
    rep(i,n){
        mp[s[i]]++;
    }
    int mx = 0;
    for(auto i : mp){
        if(i.second > mx){
            mx = i.second;
        }
    }
    vector<string> ans;
    for(auto i : mp){
        if(i.second == mx){
            ans.emplace_back(i.first);
        }
    }
    sort(ALL(ans));
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}

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

using namespace std;

const int N = 3010;
double dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  dp[0] = 1;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    double p;
    cin >> p;
    for (int j = n; j >= 0; --j) {
      dp[j + 1] += dp[j] * p;
      dp[j] *= (1 - p);
    }
  }
  cout << fixed << setprecision(20) << accumulate(dp + n / 2 + 1, dp + n + 1, 0.0);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int h, w;
vector<string> mat;
int main() {
	cin>>h>>w;
	for (int i = 0; i < h; ++i) {
		string s;
		cin>>s;
		mat.push_back(s);
	}
	for (int i = 1; i <= w+2; ++i) {
		cout<<"#";
	}
	cout<<endl;
	for (int i = 1; i <= h; ++i) {
		cout<<"#"+mat[i-1]<<"#"<<endl;
	}
	for (int i = 1; i <= w+2; ++i) {
		cout<<"#";
	}
	cout<<endl;
	return 0;
}

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

int main()
{
    while(1) {
        int a,c;
        char b;
        std::cin >> a >> b >> c;

        if (b == '?') {
            break;
        }

        if (b == '+') {
            std::cout << a + c << std::endl;
        }

        if (b == '-') {
            std::cout << a - c << std::endl;
        }

        if (b == '*') {
            std::cout << a * c << std::endl;
        }

        if (b == '/') {
            std::cout << a / c << std::endl;
        }
    }


    return 0;


}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,o,p,q,cnt=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c,ca;
queue<int> que;
signed main(){
    cin>>n>>m>>o>>p>>q;
    if(abs(n-o)<=q*(m-p)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 10516
h,w,k = map(int,input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
def count_grid(a,b):
    count = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == "#" and a >> i & 1 and b >> j & 1:
                count += 1
    return count
ans = 0
for a in range(2**h):
    for b in range(2**w):
        if count_grid(a,b) == k:
            ans += 1
print(ans)

Measured memory_bytes: 68340
s = input()
cnt = [0] * 26
n = len(s)

for c in s:
    cnt[ord(c) - ord('a')] += 1

odd = -1
for i in range(26):
    if cnt[i] % 2 == 1:
        if odd != -1:
            print(-1)
            exit()
        odd = i

cnt2 = [[] for i in range(26)]
nums = []
left = 0
for i in range(len(s)):
    c = s[i]
    ind = ord(c) - ord('a')
    if len(cnt2[ind]) * 2 + 1 == cnt[ind]:
        cnt2[ind].append((n-1)//2)
        nums.append((n-1)//2)
    elif len(cnt2[ind]) <= (cnt[ind]-1)//2:
        cnt2[ind].append(left)
        nums.append(left)
        left += 1
    else:
        num = n - 1 - cnt2[ind][cnt[ind]-1-len(cnt2[ind])]
        cnt2[ind].append(num)
        nums.append(num)

ans = 0
#print(nums)
bit = [0] * (n+1)
def add(x):
    global bit
    x += 1
    while x <= n:
        bit[x] += 1
        x += x & -x

def sum(x):
    x += 1
    res = 0
    while x:
        res += bit[x]
        x -= x & -x
    return res
for num in nums[::-1]:
    ans += sum(num)
    add(num)

print(ans)

Measured memory_bytes: 63180
N, K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
 
import numpy as np
 
 
 
Nstock = np.zeros(N)
 
cpos = 1
Nstock[cpos - 1] = 1
stock = [cpos]
loop = []
 
idx = 0
for i in range(K):
    cpos = A[cpos-1]
    if Nstock[cpos - 1]  == 1:
        idx = stock.index(cpos)
        loop = stock[idx:]
        break
    Nstock[cpos - 1] = 1
    stock.append(cpos)
    
if loop != []:
    v = (K - idx) 
    a = v %len(loop)
    print(loop[a])
else:
    print(stock[K])

Measured memory_bytes: 38484
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
int h, w, k;
vector<vecll> link;
vecint con;
////////////////////////////////////////////////
void dfs(int i, int iscon) {
  if (i != -1) {
    con[i] = iscon;
  }
  if (i == w - 2) {
    // REP(p, w - 1) { cout << con[p] << " "; }
    // cout << endl;
    REP(p, w) {
      if (p > 0 && con[p - 1]) {
        link[p - 1][p]++;
      } else if (p < w - 1 && con[p]) {
        link[p + 1][p]++;
      } else {
        link[p][p]++;
      }
    }
  } else {
    if (iscon) {
      dfs(i + 1, 0);
    } else {
      dfs(i + 1, 1);
      dfs(i + 1, 0);
    }
  }
}
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  cin >> h >> w >> k;
  if (w == 1) {
    cout << 1 << endl;
    return 0;
  }
  link = vector<vecll>(w, vecll(w, 0LL));
  con = vecint(w - 1, 0);
  dfs(-1, 0);
  // REP(i, w) {
  //   REP(j, w) { cout << setw(2) << right << link[i][j] << " "; }
  //   cout << endl;
  // }
  vector<vector<ll>> dp(h + 1, vecll(w, 0));
  dp[0][0] = 1LL;
  REP(i, h) {
    REP(j, w) {
      if (j == 0) {
        dp[i + 1][j] =
            dp[i][j] * link[j][j] % MOD + dp[i][j + 1] * link[j + 1][j] % MOD;
      } else if (j == w - 1) {
        dp[i + 1][j] =
            dp[i][j] * link[j][j] % MOD + dp[i][j - 1] * link[j - 1][j] % MOD;
      } else {
        dp[i + 1][j] = dp[i][j] * link[j][j] % MOD +
                       dp[i][j - 1] * link[j - 1][j] % MOD +
                       dp[i][j + 1] * link[j + 1][j] % MOD;
      }
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[h][k - 1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[100005];
	int i,j,k,c=0,sum=0,p=1;
	scanf(" %s",s);
	for(i=0;s[i];i++)
	if(s[i]==',')
	s[i]=' ';
	printf("%s",s);
}

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

struct Point{
  double x;
  double y;
};

void koch(int n,struct Point a,struct Point b){

  if(n == 0){
    return;
  }
  struct Point s,t,u;

  double th = M_PI * 60.0 / 180.0;

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

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

}

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

  scanf("%d",&n);

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

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

  return 0;
}




Measured memory_bytes: 2140
#include <iostream>
#include <map>
#include <stdio.h>
using namespace std;

int main ()
{
  map<string,int> m;
  int n;
  string tmp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> tmp;
    m[tmp]=1;
  }
  cout << m.size();

  return 0;
}

Measured memory_bytes: 19180
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using mint = boost::multiprecision::cpp_int; //int1024_t etc...
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;

TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	if (A > B) {
		ans += A;
		A--;
	}
	else {
		ans += B;
		B--;
	}
	if (A > B) {
		ans += A;
		A--;
	}
	else {
		ans += B;
		B--;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int count1=0;
    int count2=0;

    for (int i=0; i< s.size(); i++){
        if (i%2==0){
            if(s.at(i)=='0'){
                count1++;
            }
        }
        else {
            if(s.at(i)=='1'){
                count1++;
            }
        }
    }
    for (int i=0; i< s.size(); i++){
        if (i%2==0){
            if(s.at(i)=='1'){
                count2++;
            }
        }
        else {
            if(s.at(i)=='0'){
                count2++;
            }
        }
    }

    cout << min(count1, count2) <<endl;
}

Measured memory_bytes: 512
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<set>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 100050
#define ll long long
#define low(x) (x&(-x))
#define inf 1000000000
using namespace std;
const ll mm=998244353;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int n;
struct data{int x,y;}a[505];
void add(int &x,int y){
	x+=y;
	if (x>=mm) x-=mm;
}
int Pow(int x,int y){
	int ans=1;
	while (y) {
		if (y&1) ans=1ll*ans*x%mm;
		x=1ll*x*x%mm;
		y/=2;
	}
	return ans;
}
bool jud(int i,int j,int k){
	return (a[k].y-a[i].y)*(a[i].x-a[j].x)==(a[k].x-a[i].x)*(a[i].y-a[j].y);
}
int main(){
//	freopen("in.txt","r",stdin);
	n=read();
	rep(i,1,n) a[i].x=read(),a[i].y=read();
	int ans=Pow(2,n);
	add(ans,mm-1-n-n*(n-1)/2);
	rep(i,1,n-1) rep(j,i+1,n){
		int sum=2;
		rep(k,1,n) {
			if (k==i||k==j||!jud(i,j,k)) continue;
			if (k<j) break;
			sum++;
		}
	//	printf("%d %d %d\n",i,j,sum);
		add(ans,mm-Pow(2,sum));
		add(ans,1+sum+sum*(sum-1)/2);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  char ch[4];
  cin>>ch;
  sort(ch,ch+4);
  
    if((ch[0]==ch[1])&&(ch[1]!=ch[2])&&(ch[2]==ch[3]))
      {
      cout<<"Yes"<<endl;
      }
    else
      {
      cout<<"No"<<endl;
      }
  }


Measured memory_bytes: 3612
S = input()
T = input()
N = len(S)
M = len(T)



jdg = True

if N < M:
    print("UNRESTORABLE")
else:
    for i in range( N-M+1 ):
        jdg = True
        for j in range(M):
            if S[i+j] != T[j]:
                jdg = False
                break;
        if jdg:
            break;
    

    if jdg:
         ans = S.replace('?', 'a')
         print(ans)

    
    else:
        for i in range( N-M, -1, -1 ):
            jdg = True
            for j in range(M):
                if S[i+j] != T[j] and S[i+j] != '?':
                    jdg = False
                    break;
            if jdg:
                li = list(S)
                li[i:i+M] = T
                S = ''.join(li)
                break;

        if jdg:
            ans = S.replace('?', 'a')
            print(ans)
        else:
            print("UNRESTORABLE")



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

int A[1000];
int main(){
	int n,M=-1000,m=10000,ans=INT_MAX;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
		M=max(M,A[i]);
		m=min(m,A[i]);
	}
	
	for(int k=m;k<=M;k++){
		int x=0;
		for(int i=0;i<n;i++){
			x+=(A[i]-k)*(A[i]-k);
		}
		ans=min(x,ans);
	}
	cout << ans << endl;
	return 0;
}

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

ll gcd (ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main(){
  ll n, X;
  cin >> n >> X;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];
  x.push_back(X);
  ++n;
  sort(x.begin(), x.end());
  ll ans = x[0] - x[1];
  for (int i = 1; i < n; ++i) {
    ans = gcd(ans, x[i] - x[i - 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAX_K=100005;
const int MAX_N=105;
bool dp[MAX_K][2];
int n,k;
vector <int> A;
int main()
{
	cin>>n>>k;
	A.resize(n);
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=1;j++)
		{
			for(int stones:A)
			{
				if(i>=stones)dp[i][j]|=!dp[i-stones][!j];
			}
		}
	}
	puts(dp[k][0]?"First":"Second");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,x,cnt=0,ans=0,mi=INT_MAX;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		if(x<0){
			cnt++;
		}
		mi=min(abs(x),mi);
		ans+=abs(x);
	}
	if(cnt%2){
		cout<<ans-mi-mi<<endl;
	}
	else{
		cout<<ans<<endl;
	}
	return 0;
}

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

int N, K;
int A[100100], mini=100010, imin, ans=0;

int main () {
	cin >> N >> K;
	for(int i=1; i<=N; i++)	{
		cin >> A[i];
		if (A[i] < mini) {
			mini = A[i];
			imin = i;
		}
	}
	int L=1;
	while (L+K-1 < imin) {
		L+=K-1;
		ans++;
	}
	int R=N;
	while (R-K+1 > imin) {
		R-=K-1;
		ans++;
	}
	if (R-L+1 <= K) ans++;
	else ans+=2;
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int num;
	scanf("%d", &num);
	ll ans = 0;
	ll now = 0;
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		if (z == 0)
		{
			ans += now / 2;
			now = 0;
		}
		else now += z;
	}
	ans += now / 2;
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


def frog(num, stride, heights):
    """
    Prameters
    ---------
    num : int
        足場の数

    stride : int
        ジャンプステップ

    heights : list
        足場の高さ

    Return
    ------
    min_cost : int
        最小コスト
    """
    dp = np.zeros(num, dtype=int)
    heights = np.array(heights)
    for i in range(1, num):
        start = max(0, i - stride)
        dp[i] = min(dp[start: i] + np.abs(heights[i] - heights[start: i]))
    return dp[-1]


N = d_in()
h_list = ds_in()

print(frog(N, 2, h_list))


Measured memory_bytes: 22832
#include <iostream>
using namespace std;
int N,count=0;
void dfs(long long,unsigned char);
int main()
{
    cin>>N;
    dfs(0,0);
    cout<<count<<endl;
    return 0;
}
void dfs(long long nextNum,unsigned char flag357)
{
    if(nextNum<=N)
    {
        if(flag357==07)    // 07 is BIN 111
            count++;
        dfs(nextNum*10+3,flag357|01); // BIN 001
        dfs(nextNum*10+5,flag357|02); // BIN 010
        dfs(nextNum*10+7,flag357|04); // BIN 100
    }
}
	

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

int main() {
    char in[1010];

    int sum;

    while (scanf("%s", &in)) {
        sum = 0;

        if (strlen(in) == 1 && in[0] == '0')
            break;

        for (int i = 0; i < strlen(in); ++i) {
            sum += in[i] - '0';
        }

        printf("%d\n", sum);
    }
    return 0;
}



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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
    }

    sort (h.begin(), h.end());
    --k;
    int ans = h[k] - h[0];
    for (int i = 1; i + k < n; ++i)
    {
        if (h[i + k] - h[i] < ans)
        {
            ans = h[i + k] - h[i];
        }
        if (ans == 0) break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String[] input;
    public static void main(String[] args) {
        while(read()){
            solve();
        }

    }

    static boolean read(){
        input = sc.nextLine().split(" ");
        if(input.length >=3){
            if(input[0].equals("END") &&
                    input[1].equals("OF") &&
                    input[2].equals("INPUT"))return false;
        }
        return true;
    }

    static void solve(){
        for(int i = 0; i < input.length; i++){
            System.out.print(input[i].length());
        }
        System.out.println();
    }

}

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

int main(){
    int A,B;
    int ans = -1000000;

    cin >> A >> B ;

    ans = max(A+B,ans);
    ans = max(A-B,ans);
    ans = max(A*B,ans);

    cout << ans <<endl;

    
}

Measured memory_bytes: 256
n=int(input())
cnt=[[0 for i in range(10)] for j in range(10)]

for i in range(1,n+1):
  s=str(i)
  head=int(s[0])
  tail=int(s[-1])
  cnt[head][tail]+=1

ans=0
for h in range(0,10):
  for t in range(0,10):
    ans+=cnt[h][t]*cnt[t][h]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main(){
	int a, b;
	char x;
	cin >> a;
	cin >> x;
	cin >> b;
	if (x == '+'){
		cout << a + b << endl;
	}
	else{
		cout << a - b << endl;
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (a-1); i >= (b); --i)
#define RREP(i,n) RFOR(i,n,0)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int selectionSort(vi &a)
{
    int cnt = 0;
    REP(i, a.size()) {
        int minj = i;
        FOR(j, i, a.size()) {
            if(a[minj] > a[j]) minj = j;
        }
        if(i != minj) {
            cnt++;
            swap(a[i], a[minj]);
        }
    }
    return cnt;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];

    int cnt = selectionSort(a);
    cout << a[0];
    FOR(i, 1, n) cout << " " << a[i];
    cout << endl << cnt << endl;


    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define READ      freopen("input.txt", "r", stdin);
#define WRITE     freopen("output.txt", "w", stdout);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mint map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
const ll MAx = 1000004;

int main() {

	_cin
	// READ
	// WRITE
	ll n;
	cin >> n;
	ll a[n + 1];
	rep(i, 1, n + 1) cin >> a[i];

	ll dp[n];
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	rep(i,3,n+1){
		dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i-1]-a[i]));
	}
	cout<<dp[n]<<endl;


}

Measured memory_bytes: 5228
#include <stdio.h>

int main(void)
{
    int a, b, c, count = 0;
    scanf("%d %d %d", &a, &b, &c);

    for(int i = a; i <= b; i++){
        if(c % i == 0){
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}


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

int main(){
    int n,sum=0,min=INT_MAX;
    cin >> n;
    vector<int> x(n);
    rep(i,n){
        cin >> x.at(i);
    }

    for(int i=0;i<=100;++i){
        for(int j:x){
            sum+=(j-i)*(j-i);
        }
        if(min>sum) min=sum;
        sum=0;
    }

    cout << min <<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

unionfind = WeightedUnionFind(N)

for _ in range(M):
    l, r, d = map(int, sys.stdin.readline().rstrip().split())
    if not unionfind.same(l, r):
        unionfind.union(l, r, d)
    else:
        if unionfind.diff(l, r) != d:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 94000
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int q; cin >> q;
  LL sum = 0;
  while(q--){
	char c;
	LL p,n; cin>>p>>c>>n;
	if(c=='(') sum += n;
	else sum -= n;
	cout<< (!sum? "Yes": "No") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] xs) {
    long sum = 0;
    long[long] d = [0: 1];
    foreach (x; xs) {
        sum += x;
        d[sum]++;
    }

    long ans = 0;
    foreach (k, v; d) {
        ans += (v * (v - 1)) / 2;
    }
    return ans;
}

void main() {
    readint;
    auto xs = readints;
    writeln(calc(xs));
}


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

const int maxn = 200005;
const long long mod = 1000000007;

long long fact[maxn];

long long add_mod (long long a, long long b) {
	return (a + b) % mod;
}

long long mul_mod (long long a, long long b) {
	return (a * b) % mod;
}

long long sub_mod (long long a, long long b) {
	return (a + mod - b) % mod;
}

long long pow_mod (long long a, long long b) {
	long long res = 1, t = a;
	while (b) {
		if (b & 1)
			res = mul_mod(res, t);
		t = mul_mod(t, t);
		b >>= 1;
	}
	return res;
}

long long div_mod (long long a, long long b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

long long ncr_mod (int n, int r) {
	return div_mod(fact[n], mul_mod(fact[n - r], fact[r]));
}

void precalc () {
	fact[0] = 1LL;
	for (long long i = 1; i < maxn; ++i)
		fact[i] = mul_mod(fact[i - 1], i);
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	precalc();
	long long n, m, k;
	cin >> n >> m >> k;
	long long ans = 0LL;
	for (long long dx = 0LL; dx < m; ++dx) 
		ans = add_mod(ans, mul_mod(mul_mod(dx, mul_mod((m - dx) * n, n)), ncr_mod(n * m - 2, k - 2)));
	for (long long dy = 0LL; dy < n; ++dy) 
		ans = add_mod(ans, mul_mod(mul_mod(dy, mul_mod((n - dy) * m, m)), ncr_mod(n * m - 2, k - 2)));
	cout << ans << '\n';
}


Measured memory_bytes: 5224
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int vis[105];

int main()
{
	for(register int i=1;i<=9;++i)
	    for(register int j=1;j<=9;++j)
	        vis[i*j]=true;
	int n;
	scanf("%d",&n);
	if(vis[n]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double N=in(),K=in();
 	cout << ceil((N-1)/(K-1)) << endl;
	return 0;
}


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

bool path[10][10] = {};

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<int> v(n);
  rep(i,n) v[i] = i;
  
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--, b--;
    path[a][b] = true;
    path[b][a] = true;
  }
  
  int ans = 0;
  do{
    if(v[0] == 0){ 
      bool can = true;
      rep(i, n-1){
        if(path[v[i]][v[i+1]] == false) can = false;
      }
      if(can) ans++;
    }
  }while(next_permutation(v.begin(),v.end()));
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,a):
  d = Counter(a)

  if d[0] == n:
    return True
  if n % 3 != 0:
    return False
  if len(d) == 2 and d[0] == n // 3:
    return True
  if len(d) == 3:
    if not all(v == n//3 for v in d.values()):
      return False
    x,y,z = d.keys()
    if x ^ y ^ z == 0:
      return True
  return False





def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  print("Yes" if solve(N,a) else "No")
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 20896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	string s;
	cin >> n >> s;
	int count = 0;
	for (int i = 0; i < n - 2;i++) {
		if (s.at(i) == 'A') {
			if (s.at(i + 1) == 'B') {
				if (s.at(i + 2) == 'C')count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int ret = 0;
    string s;
    while(cin >> s){
	  string temp = s;
	  reverse(temp.begin(), temp.end());
	  ret += temp == s;
	}
	cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3196
n,m = gets.chop.split.map(&:to_i)

break_stairs = []
(1..n).each do |i|
    break_stairs[i] = false
end

m.times { break_stairs[gets.to_i] = true }

route_counts = []
route_counts[0] = 1

(1..n).each do |i|
    if break_stairs[i] == true
        route_counts[i] = 0
        next
    end
    if i == 1
        route_counts[i] = 1
        next
    end
    route_counts[i] = route_counts[i-1] + route_counts[i-2]
end

puts "#{route_counts[n] % 1000000007}"


Measured memory_bytes: 433860
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;cin>>n>>q;
  for(int i=0;i<q;i++){
    ll a,b;cin>>a>>b;
    if(n==1)cout<<min(a,b)<<endl;
    else{
      vi hog;
      while(a>=1){
	hog.pb(a);
	a=(a+(n-2))/n;
      }
      bool fl=false;
      while(b>=1){
	if(fl)break;
	for(auto nu:hog){
	  //cout<<b<<" "<<nu<<endl;
	  if(b==nu){
	    cout<<b<<endl;
	    fl=true;
	    break;
	  }
	}
	b=(b+(n-2))/n;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int ans = (h2+24)*60+m2 - h1*60-m1;
  ans %= 60*24;
  ans -= k;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
n = ni()
grid = []
 
for _ in range(n):
    s = ns()
    s = s+s
    grid.append(s)
    
for i in range(n):
    grid.append(grid[i])
    
vert = []
hrzn = []
 
for i in range(2*n):
    hrzn.append(grid[i])
    
for j in range(2*n):
    temp = ""
    for i in range(2*n):
        temp += grid[i][j:j+1]
        
    vert.append(temp)
    
    
ans = 0
b = 0 

for a in range(n):
        
    ok = True
    for i in range(n-1):
 
        if vert[b+i][a+i:a+n] != hrzn[a+i][b+i:b+n]:
            ok = False
            break
            
    if ok:
        ans += 1
            
print(ans*n)

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,string>> p(M);
  rep(i,M){
    cin >> p[i].first >> p[i].second;
  }
  set<pair<int,string>> S;
  int pena = 0;

  set<int> num;//ACを一回以上出した問題を記録
  rep(i,M){
    if(p[i].second == "AC") num.insert(p[i].first);
  }
  
  rep(i,M){
    S.insert(p[i]);
    if(p[i].second == "WA" && num.count(p[i].first)){
      if(!S.count(make_pair(p[i].first,"AC"))) pena++;
    }
  }
 
  int ac = 0;
  for(auto value : S){
    if(value.second == "AC") ac++;
  }
  cout << ac << " " << pena << endl;

 }

Measured memory_bytes: 17408
#coding:utf-8
from __future__ import division,print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの

# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=916014

# N * Mの表をつくる.すべての要素はvにする。
def make_matrix(N,M,v):
    # return [[v for i in range(M)] for j in range(N)]とも書ける。
    ret = []
    for i in range(N):
        l = []
        for j in range(M):
            l.append(v)
        ret.append(l)
    return ret


# gは行列(二次元配列)
def solve(n,m,g):
    # current_max[i][j] = 直前がjの場合のi日目の最大成長度
    # 負の数にはなりえない。
    current_max = make_matrix(m,n,-1)
    # 最初は何をあげても1.0のまま
    for i in range(n):
        current_max[0][i] = 1.0
    for i in range(1,m):
        # jは次にあげるもの
        for j in range(n):
            # 前に何をあげてたか
            # current_max[i][j] = max(current_max[i-1][k] * g[k][j]) for k in [0,n]
            for k in range(n):
                current_max[i][j] = max(current_max[i][j],
                                        current_max[i-1][k]*g[k][j])
    ret = max(current_max[m-1])
    ret = round(ret,2)
    print("%.2f" % ret)

def main():
    while True:
        # 受けとった文字列をintに変換する(リストの内包表記)
        n,m = [int(i) for i in input().split(" ")]
        if n == 0 and m == 0:
            return
        g = []
        for i in range(n):
            g.append([float(x) for x in input().split(" ")])

        solve(n,m,g)
main()

Measured memory_bytes: 4540
#include <algorithm>
#include <iostream>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;

int a[105];

bool iseq(int i,int j,int k){
    return a[i] == a[j] || a[i] == a[k] || a[j]==a[k];
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n;i++)
        cin >> a[i];
    sort(a, a + n);
    int cnt = 0;
    for (int i = 0; i < n;i++)
        for (int j = i + 1; j < n;j++)
            for (int k = j + 1; k < n;k++)
                if(a[i]+a[j]>a[k] && !iseq(i,j,k))
                    cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int n, k;
	scanf("%d %d", &n, &k);
	ll ans = 0;
	for (int i = 1; i < n; i += k) {
		++ans, --i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256