akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

# def can_reach(x, default_pos, x_moves):  # 全探索
#     for tries in range(2**len(x_moves)):  # x_moves は最大 4000, 2**100 で既に 10**30 なのでぜんぜん間に合わない。
#         result = default_pos
#         for digit in range(len(x_moves)):
#             result += (x_moves[digit] if tries & (1<<digit) else -x_moves[digit])
#         if result == x:
#             return True
#     return False

# def can_reach(x_aim, default_pos, x_moves):  # ソートして貪欲 → ACだが嘘解法かもしれない。
#     for i in sorted(x_moves, reverse=True):
#         if x_aim > default_pos:
#             default_pos += i
#         else:
#             default_pos -= i
#     if default_pos == x_aim:
#         return True
#     else:
#         return False

# def can_reach(x_aim, default_pos, x_moves):  # dp → TLE
#     def dp(i, pos):
#         if i == 0:
#             if pos == default_pos: return True
#             else: return False
#         else:
#             return dp(i-1, pos - x_moves[i-1])  or dp(i-1, pos + x_moves[i-1])

#     return dp(len(x_moves), x_aim)

# def can_reach(x_aim, default_pos, x_moves):  # dp with table → TLE
#     dp = [[False for _ in range(20000)] for _ in range(len(x_moves)+1)]  # 20000 * 8000 = O(10**8) ぐらい
#     def read_dp(i, j):
#         return dp[i][j+10000]
#     def write_dp(i, j, k):
#         dp[i][j+10000] = k
#     write_dp(0, default_pos, True)
#     for i in range(len(x_moves)):
#         for j in range(20000):
#             if dp[i][j] == True:
#                 dp[i+1][j+x_moves[i]] = True
#                 dp[i+1][j-x_moves[i]] = True
#     return read_dp(len(x_moves), x_aim)
    

def can_reach(x_aim, default_pos, x_moves):  # dp with set → AC
    dp = set([default_pos])
    for i in x_moves:
        new_dp = []
        for j in dp:
            new_dp.append(j+i)
            new_dp.append(j-i)
        dp = set(new_dp)
    return x_aim in dp


def main(): 
    s = SI()
    x, y = LI()

    x_moves = []
    y_moves = []
    moving_x = True
    for i in s.split('T'):
        if moving_x:
            x_moves.append(len(i))
        else:
            y_moves.append(len(i))
        moving_x = not moving_x

    if can_reach(x, x_moves[0], x_moves[1:]) and can_reach(y, 0, y_moves):
        print('Yes')
    else:
        print('No')


main()

Measured memory_bytes: 3928
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n, m; cin >> n >> m;
  int sum = (n+m)*(n+m-1);
  sum /= 2;
  cout << sum - (n*m) << endl;
  system("pause");
}

Measured memory_bytes: 504
N,K=map(int,input().split())

#a%K=A, b%K=B, c%K=C としたとき,
#A=B=C=0 か、
#A=B=C=K/2 (Kは偶数) のどちらが成り立つ

#N以下のKの倍数の数
kt=N//K

#A=B=C=0を満たす組の数
z=kt*kt*kt

#A=B=C=K/2 (Kは偶数) を満たす組の数
o=0
if K&1==0:
    an=kt+(1 if N%K>=K/2 else 0)
    o=an**3

print(z+o)

Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 3e5 + 12; //check the limits, dummy

int main()
{

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    ll n;
    cin >> n;

    ll cur = 1, ans = 0;

    FOR (i, 0, n) {
        ll x;
        cin >> x;
        if (x == cur) cur++;
        else ans++;
    }

    cout << (cur == 1 ? -1LL : ans) << '\n';

    return  0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N,A,B;

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


	int x=min(N*A,B);
		cout<<x<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int c=0;
    string s;
    cin>>s;
    for(auto x:s)
        c+= x=='2';
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
value = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    value.append([a - 1, b - 1, c, d])
ans = 0
for comb in itertools.combinations_with_replacement(range(1, m + 1), n):
    temp = 0
    for v in value:
        if comb[v[1]] == comb[v[0]] + v[2]:
            temp += v[3]
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 9216
"use strict";
    
const main = arg => {
    const N  = arg.split("\n")[0].split(" ")[0];
    const A  = arg.split("\n")[0].split(" ")[1];
    const B  = arg.split("\n")[0].split(" ")[2];
    let list = [];
    
    for(let i=1; i<=N; i++) {
        let sum = parseInt(String(i).split("").reduce((m,n)=>parseInt(m)+parseInt(n)));
        if(sum >= A && sum <= B) list.push(i);
    }
    
    console.log(list.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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


void solve(long long N, std::vector<long long> A){
    vector<pair<ll,ll>> values(N+1);
    vector<ll> num(N+1,0);
    set<ll> st;    
    for(int i= 0;i<N;i++){
        num[A[i]]++;
        st.insert(A[i]);
    }
    ll allV = 0;
    for (auto itr = st.begin(); itr != st.end(); ++itr) {
        ll v = *itr;
        ll n = num[v];
        if(n <= 1){
            values[v].first = 0;
            values[v].second = 0;
            continue;
        }
        ll f = (n * (n-1))/2;
        ll s = ((n-1) * (n-2))/2;
        values[v].first = f;
        values[v].second = s; 
        allV += f;
    }
    for(int i=0;i<N;i++){
        cout << allV -values[A[i]].first + values[A[i]].second << endl;
    }


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 13824
#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;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = (ll)1e18;
const ll maxn = 1e9+1;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x, ll y, ll mod) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x, ll mod) {return power(x,mod-2,mod);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng((ll)chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
void solve()
{
    ll n;
    cin>>n;
    string res = "";
    while(n) {
        n--;
        res += char('a'+n%26);
        n /= 26;
    }
    reverse(all(res));
    cout<<res<<endl;
}
int main()
{
    // ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k=0;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  for(int j=1;j<n-1;j++){
    int x=a.at(j-1),y=a.at(j+1);
    if(a.at(j)>min(x,y)&&a.at(j)<max(x,y))k++;
  }
cout<<k<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	string a;
	int vis[30];
	bool flag = true;
	cin >> a;
	memset(vis,0,sizeof(vis));
	for(int i = 0 ; i < a.length() ; i++)
		vis[a[i] - 'a']++;
	for(int i = 0 ; i < 26 ; i++)
	{
		if(vis[i] > 1)flag = false;
	}
	if(flag)cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while((A>0)&&(C>0)){
    C=C-B;
    if(C<=0){
      cout << "Yes" << endl;
      break;
    }
    A=A-D;
    if(A<=0){
      cout << "No" << endl;
    }
  }
}
    

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    int N, K;
    long long n = 0, s = 0;
    cin >> N >> K;
    
    n = N/K;
    
    if ( K%2==0) {
        for ( int i = 1; i <= N; i++) {
            if ( i%K==(K/2)) s++;
        }
    }
    
    cout << n*n*n + s*s*s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long

using namespace std;
int n,a[100005][3],dp[100005][3];

int solve(int i,int las){
    if(i==n)return 0;
    int &ret=dp[i][las];
    if(ret!=-1)return ret;
    for(int j=0;j<3;j++){
        if(j==las)continue;
        ret=max(ret,a[i][j]+solve(i+1,j));
    }
    return ret;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof dp);
    int ans=-1;
    for(int i=0;i<3;i++){
        ans=max(ans,solve(1,i)+a[0][i]);
    }
    cout<<ans;
    return 0;
}



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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	vector<set<char>> v(2);
	v[0].insert('R');
	v[0].insert('U');
	v[0].insert('D');
	v[1].insert('L');
	v[1].insert('U');
	v[1].insert('D');

	bool ok = true;
	string s;
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; ++i)
		ok &= v[i&1].find(s[i]) != v[i&1].end();
	if (ok)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll x;cin>>x;
    ll p=x/11;
    ll q=x%11;

    if(q==0){
        cout<<2*p<<"\n";
    }
    else if(q<=6){
        cout<<2*p+1<<"\n";
    }
    else{
        cout<<2*(p+1)<<"\n";
    }
}


Measured memory_bytes: 256
n=int(input())
array=[int(input())  for i in range(n)]

ans1=max(array)
answer=[ans1]*n

for i in range(n):
  if array[i]==ans1:
    array.pop(i)
    ans2=max(array)
    answer[i]=ans2
    break
for i in range(n):
  print(answer[i])


Measured memory_bytes: 14060
# ABC 114 C

import itertools

def get_list(N, rep):
    count = 0
    a = list(itertools.product([3, 5, 7], repeat=rep))
    delList = []
    for e in a:
        if 3 not in e or 5 not in e or 7 not in e:
            delList.append(e)
    for e in delList:
        a.remove(e)
    for e in a:
        val = 0
        for i in range(rep):
            val += e[i] * 10**(rep-i-1)
        if val <= N:
            count += 1
    return count

def resolve():
    N = int(input())
    ans = 0
    for i in range(9):
        ans += get_list(N, i+1)
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 6260
/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 200005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

void solve(){
    vector<ll> v;
    ll n, k, sum = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        ll x;
        cin >> x;
        v.pb(x);
        sum += x;
    }
    sort(v.rbegin(), v.rend());
    for(int i=0;i<min(n, k);i++){
        sum -= v[i];
    }
    cout << sum << endl;
}


int main() {

    int tc;
    tc = 1;
    while(tc--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a+(b/2));
	}
}

Measured memory_bytes: 23636
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  ll ans = 0;
  vector<string> s(n);

  rep(i,n)
  {
    string buf;
    cin >> buf;
    vsort(buf);
    s[i] = buf;
  }

  map<string,ll> m;

  rep(i,n)
  {
    m[s[i]]++;
  }

  for(auto itr=m.begin();itr!=m.end();itr++)
  {
    ans += itr->second * (itr->second - 1) / 2;
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 12032
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1e+15;


void solve(istream &cin) {
    ll A, B, K;
    cin >> A >> B >> K;
    if(!cin) return;
    
    ll ans = min(A, B);
    int k = 0;
    while(k < K){
        if(A % ans == 0 and B % ans == 0){
            k++;
        }
        ans--;
    }
    ans++;
    
    cout << ans  << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#traveling salesman
k, n = map(int, input().split())
homes = list(map(int, input().split()))
d_list = []
for i in range(n-1):
    dist = homes[i+1] - homes[i]
    d_list.append(dist)
dist_0 = homes[0] + (k - homes[n-1])
d_list.append(dist_0)
print(k - max(d_list))

Measured memory_bytes: 25840
N,M=map(int,input().split())
A=[input().rstrip() for i in range(N)]
B=[input().rstrip() for i in range(M)]
for i in range(N-M+1):
  for j in range(N-M+1):
    f=True
    for k in range(M):
      if A[i+k][j:j+M]!=B[k]:
        f=False
        break
    if f:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> num(N);
  for(int i=1; i<N; i++) {
    string tmp = S.substr(i-1, 2);
    num[i] = num[i-1] + (tmp == "AC" ? 1 : 0);
  }
  // for(int i=0; i<N; i++)
  //   cout << num[i] << ' ';
  // cout << endl;
  for(int i=0; i<Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << num[r-1] - num[l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
typedef pair<int, int> P;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, -1, 0, 1};

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int h, w; cin >> h >> w;
		vector<string> maze(h);
		rep (i, h) {
			cin >> maze[i];
		}
		int ans = 0;
		rep (si, h) {
			rep (sj, w) {
				if (maze[si][sj] == '#') continue;
				vector<vector<int>> dist(h, vector<int>(w, INF));
				queue<P> q;	
				auto update = [&](int i, int j, int x) {
					if (dist[i][j] != INF) return;
					dist[i][j] = x;
					q.push(P(i, j));
				};
				update(si, sj, 0);
				while(!q.empty()) {
					int i = q.front().first;
					int j = q.front().second; q.pop();
					rep (dir, 4) {
						int ny = i + dy[dir], nx = j + dx[dir];
						if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
						if (maze[ny][nx] == '#') continue;
						update(ny, nx, dist[i][j] + 1);
					}
				}
				rep (i, h) {
					rep (j, w) {
						if (dist[i][j] != INF) ans = max(ans, dist[i][j]);
					}
				}
			}
		}
		cout << ans << endl;
    return;
}

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



Measured memory_bytes: 256
object Main extends App {
  var input = readLine.toInt
  var sum = 0
  
  if(input >= 500) {
    var tempo = (input / 500).toInt
    sum = sum + tempo * 1000
    input = input - tempo * 500
  }
  
  sum = sum + (input / 5).toInt * 5
  
  println(sum)
  
}

Measured memory_bytes: 25504
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

int main(){
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  vector<vector<ll>> p(n, vector<ll>(11));
  rep(i,n)rep(j,10){ cin >> f[i][j]; }
  rep(i,n)rep(j,11){ cin >> p[i][j]; }

  ll ans=-longinf;
  for(int i=1; i<1024; i++){
    ll cur=0;
    for(int j=0; j<n; j++){
      int cnt=0;
      rep(k,10)if(f[j][k]==1 && bit(i,k)){ cnt++; }
      cur += p[j][cnt];
    }
    ans = max(ans,cur);    
  }

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#define ll long long
#define INF 1000000000
#define clr(x) memset(x,0,sizeof(x))
using namespace std;

inline int read()
{
	register int ret=0,w=1,c=getchar();
	while(!isdigit(c))w=c=='-'?-1:1,c=getchar();
	while(isdigit(c))ret=ret*10+c-'0',c=getchar();
	return ret*w;
}

int main()
{
#ifdef anantheparty
	//freopen("in.txt","r",stdin);
#endif
	int a=read(),b=read(),c=read();
	printf("%d\n",a+b+c-max(a,max(b,c)));
	return 0;
}



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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool eqigc(string T, string W) {
    bool ret = true;
    if (T.size() == W.size()) {
        int i;
        for (i=0;i<T.size();i++) {
            if ('A' <= T[i] && T[i] <= 'Z') T[i]-='A'-'a';
            if ('A' <= W[i] && W[i] <= 'Z') W[i]-='A'-'a';
            if (T[i] != W[i]) {
                ret = false;
                break;
            }
        }
    } else {
        ret = false;
    }
    return ret;
}
int main() {
    string W,T;
    int ans=0;
    cin >> W;
    while (cin >> T) {
        if (T == "END_OF_TEXT") break;
        else if (eqigc(T,W)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    int k;
    string s;
    cin>>k>>s;

    if(s.length()>k){
        cout<<s.substr(0,k)<<"...\n";
    }
    else{
        cout<<s<<"\n";
    }


    return 0;
}


Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int a,b,i;
string s;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>s;
	for(i=0;i<a;i++)if(!((s[i]-'0')>=0 && (s[i]-'0')<=9))rc("No");
	if(s[a]!='-')rc("No");
	for(i=a+1;i<s.size();i++)if(!((s[i]-'0')>=0 && (s[i]-'0')<=9))rc("No");
	rc("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{
	//FILEIO
 	start_routine
	int n;
	cin>>n;
	int dp[n + 1] = {0};
	int h[n + 1];
	h[0] = mod;
	int i;
	fr(i,1,n + 1)
	{
		cin>>h[i];
	}
	fr(i,2,n + 1)
	{
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}

	cout<<dp[n];
 
 	end_routine
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CTaxIncrease {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        int x, y;
        cin >> x >> y;
        int res = -1;
        for (int i = 1; i < 50000; ++i) {
            if (floor(i * 0.08) == x && floor(i * 0.1 / 1) == y) {
                res = i;
                break;
            }
        }
        cout << res << endl;
    }
};


int main() {
    CTaxIncrease solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long 
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef double f80;
#ifndef LOCAL
#define endl '\n'
#endif

// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
ll pwr(ll a,ll b){
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
const int N = 2e5 + 5;
int dp[N], a[N];
vector<int> pos[N];
void solve(){
    int n;
    cin >> n;
    fr(i, 1, n){
        cin >> a[i];
        pos[a[i]].pb(i);
    }
    dp[1] = 1;
    fr(i, 1, n - 1){
        dp[i] %= mod;
        dp[i + 1] += dp[i];
        dp[i + 1] %= mod;
        auto it = upper_bound(all(pos[a[i]]), i);
        if(it == pos[a[i]].end()) continue;
        int p = *it;
        if(p != i + 1){
            dp[p] += dp[i];
            dp[p] %= mod;
        }
    }
    cout << dp[n];
 }
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111


	void solve(){

		ini(n);
		vi morty;
		FOR(i,0,n){
			ini(x);
			morty.push_back(x);
		}
		map<int,int>map1;
		int rick = 0;
		FOR(i,0,n){
			map1[i+morty[i]]++;
			int tmp = i-morty[i];
			rick+=map1[tmp];
		}
		out(rick);





	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 27444
#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()

int main() {
    int r, D, x;
    cin >> r >> D >> x;

    rep(i, 10){
        x = r*x - D;
        cout << x << endl;
    }
}

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

int main(){
    int n;  cin >> n;
    vector<pair<int, int> >task;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        task.emplace_back(b, a);
    }
    sort(task.begin(), task.end());
    int sum = 0;
    bool flag = true;
    for(auto v :task){
        sum += v.second;
        if(sum > v.first){
            flag = false;
            break;
        }
    }
    cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll n,m; cin>>n>>m;
    if(n==m) cout<<"Yes";
    else cout<<"No";
}

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

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (t[i] != s[i]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		System.out.println(a*b+" "+2*(a+b));
		scn.close();
	}

}

Measured memory_bytes: 25804
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_ret_int(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_ret_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
*A, = map(int, input().split())
lcm_n = lcm_ret_int(*A) - 1
ans = 0
for i in range(N):
    ans += lcm_n % A[i]
print(ans)

Measured memory_bytes: 5368
import Control.Monad
import Control.Applicative
import Data.List


-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine

-- getBysplit = map read . words <$> getLine

main :: IO()
main = do
  n <- readLn :: IO Int
  s <- getLine
  k <- readLn :: IO Int
  let kstr = s !! (k-1)
  let ans = map (\x -> if x == kstr then x else '*') s
  putStrLn ans


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

int main() {
  int N; cin >> N;
  int cnt = 0, ans = 0;
  for (int i = 1; i <= N; i += 2) {
    for (int j = 1; j <= N; j += 2) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
    cnt = 0;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void)
{
	int n;
	double a,b,c,d,e,f;
	double det, ia, ib, ic, id;
	double x,y;
	char buf[32];
	while(fgets(buf,32,stdin)!=NULL){
		n=sscanf(buf,"%lf %lf %lf %lf %lf %lf",&a,&b,&e,&c,&d,&f);
		if(n!=6)break;
		det = 1./(a*d - b*c);
		ia=d*det;
		ib=-b*det;
		ic=-c*det;
		id=a*det;
		x=ia*e+ib*f;
		y=ic*e+id*f;
		printf("%.3f %.3f\n", round(x*1000)/1000,round(y*1000)/1000);
	}
	return 0;
}

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

int main(){
    int n, m;

    cin >> n >> m;
    // cout << n << " " << m << endl;

    int A[n][m];
    int B[m];

    // A
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    // B
    for(int i = 0; i < m; i++){
        cin >> B[i];
    }

    // 出力 A
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            // cout << " " << A[i][j];
        }
        // cout << endl;
    }
    // 出力 B
    for(int i = 0; i < m; i++){
        // cout << B[i];
        // cout << endl;
    }

    // 計算
    for(int i = 0; i < n; i++){
        int sum = 0;
        for(int j = 0; j < m; j++){
            // cout << " " << A[i][j];
            sum += (A[i][j] * B[j]);
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
using namespace std;
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

long long lasts[2001];


long long addm[2001][2001];

int main(void) {
	/*int x, a;
	scanf("%d %d", &x, &a);
	if (x < a) {
		printf("0\n");
	}
	else {
		printf("10\n");
	}*/
	/*int n, x;
	scanf("%d %d", &n, &x);
	int l[101];
	for (int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	int d=0;
	int count = 1;
	for (int i = 0; i < n; i++) {
		d = d + l[i];
		if (d <= x)count++;
	}
	printf("%d", count);*/

	/*int w, h, x, y;
	scanf("%d %d %d %d", &w, &h, &x, &y);
	double W = w, H = h;
	double ans = W * H / 2.0;
	if (!(w==2*x&&h==2*y)) {
		printf("%lf %d\n", ans, 0);
	}
	else {
		printf("%lf %d\n", ans, 1);
	}*/

	/*long long n, k;
	scanf("%lld %lld", &n, &k);
	int a[100001];
	for (long long i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	long long count = 0;
	int endi = 0;
	long long temp = 0;
	temp += a[0];
	for (int i = 0; i < n; i++) {//start
		temp -= (i==0) ? 0 : a[i - 1];
		while (1) {
			if (temp >= k) {
				count += n - endi;
				break;
			}
			else {
				if (endi == n-1)break;
				endi++;
				temp += a[endi];
			}
		}
	}
	printf("%lld\n", count);*/
	vector<long long> v(2001,0);

	int n, m;
	int s[2001], t[2001];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &t[i]);
	}

	for (int i = 0; i < m; i++) {
		for (int j = n - 1; j >= 0; j--) {
			if (t[i] == s[j]) {
				//lasts[j]++;
				addm[i][j] = 1;
				/*for (int k = 0; k <= j - 1; k++) {
					lasts[j] += lasts[k];
					lasts[j] %= 1000000007;
				}*/
				
			}
		}
	}
	long long ans = 0;
	/*for (int k = 0; k < n; k++) {
		ans += lasts[k];
		ans %= 1000000007;
	}*/
	long long rowsum;
	for (int i = 1; i < m; i++) {
		addm[i][0] += addm[i - 1][0];
		rowsum = addm[i - 1][0];
		for (int j = 1; j < n; j++) {
			rowsum += addm[i - 1][j];
			rowsum %= 1000000007;
			addm[i][j] += (addm[i][j]) ? (rowsum) : addm[i-1][j];
			addm[i][j] %= 1000000007;
		}
	}
	ans++;
	for (int i = 0; i < n; i++) {
		ans += addm[m - 1][i];
		ans %= 1000000007;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
    float l[11];
    float v1,v2;
    char s;
    while(1)
    {
        for(int i=1;i<=10;i++){
            cin >> l[i] >> s;
        }
        cin >> v1 >> s >> v2;
        if(cin.eof()) break;
       

        float t,la;
        float lsum=0;
        for(int i=1;i<=10;++i){
            lsum+= l[i];
        }

        t = lsum/(v1+v2);
        la = v1*t;
        lsum = 0;
        for(int i=1;i<10;i++)
        {
            lsum += l[i];
            if(lsum >= la){ cout << i << endl; break;}
        }
        if(lsum < la)cout << 10 << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
const int N = 5005 , mod = 1000000007;
struct node{int to,next;}e[N<<1];
int f[N][N],n,head[N],cnt,siz[N],g[N],tmp[N];
void add(int x,int y){e[cnt]=(node){y,head[x]};head[x]=cnt++;}
void dfs(int x,int from)
{
	siz[x] = f[x][1] = 1;
	for(int i=head[x];i!=-1;i=e[i].next)if(e[i].to!=from)
	{
		int to1 = e[i].to;dfs(e[i].to,x);
		for(int j=1;j<=siz[x]+siz[to1];j++)tmp[j] = 0;
		for(int j=1;j<=siz[x];j++)
			for(int k=0;k<=siz[to1];k++)
				tmp[j+k] = (tmp[j+k] + (ll)f[x][j] * f[to1][k])%mod;
		siz[x] += siz[to1];
		for(int j=1;j<=siz[x];j++)f[x][j] = tmp[j];
	}
	for(int i=2;i<=siz[x];i+=2)f[x][0] = ( f[x][0] - (ll)f[x][i]*g[i])%mod;
}
int main()
{
	scanf("%d",&n);memset(head,-1,sizeof(head));
	for(int i=1,x,y;i<n;i++)scanf("%d%d",&x,&y),add(x,y),add(y,x);g[0] = 1;
	for(int i=2;i<=n;i+=2)g[i] = (ll)g[i-2]*(i-1)%mod;dfs(1,0);
	printf("%d\n",(mod - f[1][0]%mod)%mod);
}



Measured memory_bytes: 97152
use std::io;


fn main() {
    let (x, a, b) = {
        let i = read::<isize>();
        (i[0], i[1], i[2])
    };
    if (x - a).abs() < (x - b).abs() {
        println!("A");
    } else {
        println!("B");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    x1,y1,x2,y2=INTM()
    w=x2-x1
    h=y2-y1
    x3=x2-h
    y3=y2+w
    x4=x3-w
    y4=y3-h
    print(x3,y3,x4,y4)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
while hws = gets.chomp
    h,w = hws.split(' ').map{|n| n.to_i}
    if h==0 && w==0
        break
    else
        puts "#"*w
        (h-2).times do
            puts "#" + "."*(w-2) + "#"
        end
        puts "#"*w
        puts ""
    end
end

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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

int main(){
  int n; cin >> n;
  n%=10;
  if(n==2 || n==4 || n==5 || n==7 || n==9) puts("hon");
  if(n==0 || n==1 || n==6 || n==8) puts("pon");
  if(n==3) puts("bon");
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

// Segment Tree
// セグメント木
// 区間最小
// i = 0～
#define SEGT_N ((1<<17)) // > 10^5
#define SEGT_INVALID (INT64_MAX)
typedef ll st;
st segt[SEGT_N*2];

void SEGTinit(void)
{
    for(int i=0;i<SEGT_N*2;i++) segt[i] = SEGT_INVALID;
}

void SEGTupdate(int i, st val)
{
    i = SEGT_N-1+i;
    segt[i] = min(segt[i],val);
    // segt[i] += val;
    while(i)
    {
        i = (i-1)/2;
        segt[i] = min(segt[i*2+1], segt[i*2+2]);
        // segt[i] = segt[i*2+1] + segt[i*2+2];
    }
}

st SEGTget_sub(int l, int r, int i, int il, int ir)
{
    if((ir < l) || (r < il) ) return SEGT_INVALID; // 被らない
    if((l <= il) && (ir<=r) )
    {
        return segt[i]; // 完全にかぶっている
    }else
    {
        st lv = SEGTget_sub(l,r,i*2+1,il, (il+ir+1)/2-1);
        st rv = SEGTget_sub(l,r,i*2+2, (il+ir+1)/2,ir);
        return min(lv,rv);
        // return lv+rv;
    }
}

st SEGTget(int l, int r)
{
    return SEGTget_sub(l,r,0,0,SEGT_N-1);
}

typedef struct 
{
    ll l;
    ll r;
    ll c;
}p;
int acs_p(const void *a, const void *b){return ((p*)a)->l - ((p*)b)->l;} /* 1,2,3,4.. */
p ps[MAXN];



int main(void)
{
    ll n,m;
    scanf("%ld %ld",&n,&m);
    for(int i=0;i<m;i++) scanf("%ld %ld %ld",&ps[i].l,&ps[i].r,&ps[i].c);

    qsort(ps,m,sizeof(p),acs_p);

    SEGTinit();
    SEGTupdate(1,0);

    for(int i=0;i<m;i++)
    {
        ll c = SEGTget(ps[i].l,ps[i].r);
        if(c!=SEGT_INVALID) SEGTupdate(ps[i].r,c+ps[i].c);
    }
    
    ll ans=SEGTget(n,n);
    if(ans == SEGT_INVALID) ans = -1;
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 6652
#include<stdio.h>
int main(){
	int a,i,b=0 ;
	scanf("%d",&a);
	for(i=1;i<10;i++){
		if(a%i==0&&a/i<10){
		printf("Yes");
		b=1;
		break;
		
		}
	}
	if(b==0){
		printf("No");
	}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll kai[(1<<18)];

ll mp(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b == 1) return a;
    ll ans = mp(a, b/2);
    ans *= ans;
    ans %= mod;
    if (b&1) ans *= a;
    return ans % mod;
}

ll inv(ll k) {
    return mp(k, mod - 2);
}

ll c(ll n, ll k) {
    if (k == 0 || n == k) return 1LL;
    return kai[n] * inv(kai[k]) % mod * inv(kai[n - k]) % mod;
}

ll f(ll n, ll m, ll k) {
    ll ans = 0;
    for (ll i = 1LL; i <= n; i++) {
        ans += i * (n - i) % mod * m % mod * m % mod * c(n * m - 2, k - 2) % mod;
        ans %= mod;
    }
    return ans;
}

void init() {
    kai[1] = 1;
    for (ll i = 2; i < (1 << 18); i++) {
        kai[i] = kai[i-1] * i;
        kai[i] %= mod;
    }
}

int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    init();
    cout << (f(n,m,k) + f(m,n,k)) % mod << endl;
    return 0;
}


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

int main() {
  int num;
  double kekka = 0;
  double Max = 0;
  double L = 0;
  double R = 0;
  int cnt = 0;
  cin >> num;
  
  vector<double> vecX(num);
  vector<double> vecY(num);
  vector<double> tmp(num);
  
  for(int i = 0; i < num; i++){
    cin >> vecX.at(i) >> vecY.at(i); 
    tmp.at(i) = i;
  }
  
  do{
    for(int i = 0; i < num-1; i++){
      L = vecX.at(tmp.at(i)) - vecX.at(tmp.at(i+1));
      R = vecY.at(tmp.at(i)) - vecY.at(tmp.at(i+1));
      L = L*L + R*R;
      Max += sqrtl(L); 
      //Max += sqrtl((vecX(tmp.at(i)-1) - vecX(tmp.at(i+1)-1)) + (vecY(tmp.at(i)-1) - vecY(tmp.at(i+1)-1)));
    }
    cnt++;
  } while(next_permutation(tmp.begin(), tmp.end()));

  kekka = Max / (double)cnt;
  cout <<setprecision(8) << kekka;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256