akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;

using System.Linq;
public class dp_b {
    //https://atcoder.jp/contests/dp/tasks/dp_b
    static DateTime START_TIME;
    static int INT_INF = int.MaxValue / 2;
#if !MYTEST
    public static void Main() {
        START_TIME = DateTime.Now;
        System.Console.WriteLine(Answer());
    }
    public static void debugOut(string str) { }
    public static string ReadLine() {
        return System.Console.ReadLine();
    }
#endif
    public static string Answer() {
        var p = ReadLine().Trim().Split(' ');
        //              1234567890
        // int.MaxValue=2147483647
        var N = int.Parse(p[0]);
        var K = int.Parse(p[1]);
        var h = new int[N];
        var dp = new int[N];
        p = ReadLine().Trim().Split(' ');
        for (var i = 0; i < N; i++) {
            h[i] = int.Parse(p[i]);
            dp[i] = INT_INF;
        }
        dp[0] = 0;
        for (var i = 1; i < N; i++) {
            for (var k = 1; k <= K; k++) {
                if (i - k >= 0) {
                    var cost = Math.Abs(h[i] - h[i - k]);
                    dp[i] = Math.Min(dp[i], dp[i - k] + cost);
                }
            }
        }

        return dp[N - 1].ToString();
    }

    #region LOCAL
#if MYTEST
    static System.IO.StreamReader FS = null;
    public static void Main() {
        START_TIME = DateTime.Now;
        if (System.IO.File.Exists("dp_b.txt")) {
            FS = new System.IO.StreamReader("dp_b.txt");
        }
        try {
            while (true) {
                debugOut("<TEST MODE>\n");
                START_TIME = DateTime.Now;
                var testcase = seekNextCase();
                var ans = Answer();
                System.Console.WriteLine(ans);  // debug
                debugOut($"{(DateTime.Now - START_TIME).TotalMilliseconds} msec.\n");
                if (FS != null && !FS.EndOfStream) {
                    var expect = ReadLine();
                    var res = ans == expect ? "OK" : "NG";
                    debugOut($"{testcase} {res} expect={expect} actual={ans}\n");
                }
            }
        } finally {
            if (FS != null) FS.Close();
        }
    }
    public static void debugOut(string str) {
        System.Console.Error.Write(str);
    }
    public static string ReadLine() {
        if (FS != null && !FS.EndOfStream) {
            var line = FS.ReadLine();
            // debugOut(line + "\n");
            if (FS.EndOfStream) {
                FS.Close();
                FS = null;
            }
            return line;
        }
        return System.Console.ReadLine();
    }
    public static string seekNextCase() {
        while (FS != null) {
            var line = ReadLine();
            if (line.StartsWith("---")) {
                return line;
            }
        }
        return null;
    }
#endif
    #endregion
}


Measured memory_bytes: 37360
#include<cstdio>
int main(){
    int a,b,ans=0;
    scanf("%d%d",&a,&b);
    for(int i=a;i<=b;i++){
        if(i/10000==i%10&&((i%10000)/1000==(i%100)/10))ans++;
    }
    printf("%d",ans);
    return 0;
}

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

int main()
{
    int s1, s2, s3;
    int s;
    cin >> s;

    s1 = s / 100;

    if(s1 == 1){
        s2 = (s - 100) / 10;

        if(s2 == 1){
            s3 = s - 110;
        }
        else{
            s3 = s - 100;
        }

    }
    else{
        s2 = s /10;

        if (s2 == 1) {
            s3 = s - 10;
        }
        else{
            s3 = s;
        }

    }
    
    cout << s1 + s2 + s3 << '\n';

    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int tax(int a, int x) {
    return a * (100 + x) / 100;
}

int solve(int x, int y, int s) {
    int ret = 0;
    for (int i = 1; i < s; i++) {
        for (int j = 1; j < s; j++) {
            if (tax(i, x) + tax(j, x) != s) { continue; }
            chmax(ret, tax(i, y) + tax(j, y));
        }
    }
    return ret;
}

signed main() {
    while (true) {
        int x, y, s;
        cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) { break; }
        cout << solve(x, y, s) << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
   int n; cin>>n;
   vector<int> v(n);
   vector<int> c(n);
   rep(i,0,n)cin>>v[i];
   rep(i,0,n)cin>>c[i];
   vector<int> raw(n);
   rep(i,0,n)raw[i]=v[i]-c[i];
   int ans=0;
   rep(i,0,n){
       if(raw[i]>0) ans+=raw[i];
   }
   cout<<ans<<endl;
}


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

int main(){
  int h1, h2, m1, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  int h = h2 - h1;
  int m = m2 - m1;
  int t = h * 60 + m;
  int ans = t - k;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define sz(a) (a.size())
#define int long long
#define SYNC ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(c) c.begin(), c.end()
#define pb push_back
#define F first
#define S second
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x, y) cout << #x << " = " << x << " , " << #y << " = " << y << endl;
#define debug3(x, y, z) cout << #x << " = " << x << " , " << #y << " = " << y << " , " << #z << " = " << z << endl;
const int M = 1000000007;
const int N = 1e9 + 1;

signed main()
{
    int n , k , i;
    cin>>n>>k;
    int a[k];
    int sum=0;
    for(i=0 ; i<k ; i++) cin >> a[i] , sum+=a[i];
    if(sum >= n ) cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int ll
set <int> s;
int pos[102020];
int n;
int ans;
int32_t main()
{
	usecppio
	cin >> n;
	for (int i = 1; i<=n; i++)
	{
		int x;
		cin >> x;
		pos[x] = i;
	}
	s.insert(0);
	s.insert(n+1);
	for (int i = n; i>0; i--)
	{
		s.insert(pos[i]);
		auto p = s.find(pos[i]);
		auto l = p; l--;
		auto r = p; r++;
		int pp = *p;
		int lp = *l, rp = *r;
		if (lp)
		{
			l--;
			int lp2 = *l;
			ans += (i) * (lp-lp2) * (rp - pp);
		}
		if (rp <= n)
		{
			r++;
			int rp2 = *r;
			ans += (i) * (rp2-rp) * (pp-lp);
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 5760
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val Y = sc.nextLong

    for (x <- 0 to N; y <- 0 to N - x) {
      val z = N - x - y
      if (x * 10000L + y * 5000L + z * 1000L == Y) {
        println(s"$x $y $z")
        sys.exit
      }
    }
    println(s"-1 -1 -1")
  }
}

Measured memory_bytes: 27316
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int s;
	cin>>s;
	int a=s/100,b=s%100;
	int c=s/1000,d=b/10;
	if(c==0)a=a%10;
	if(d==0)b=b%10;

	if(a<=12&&b<=12&&a>0&&b>0)cout<<"AMBIGUOUS"<<endl;
	else if(a>0&&a<=12)cout<<"MMYY"<<endl;
	else if(b<=12&&b>0)cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;

	return 0;

}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = long.Parse(line[0]);
        var b = long.Parse(line[1]);
        var k = long.Parse(line[2]);
        var count = 0;
        while (true)
        {
            if (a % 2 == 1) a--;
            b += a / 2;
            a /= 2;
            count++;
            if (count == k) break;
            if (b % 2 == 1) b--;
            a += b / 2;
            b /= 2;
            count++;
            if (count == k) break;
        }
        Console.WriteLine("{0} {1}",a,b);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(a, b, n) for(int i = 0; i < n; i++) b[i] = a[i]

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
using namespace std;

void solve(){
    char x;
    cin >> x;
    cout << (char)(x + 1);
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("file.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}



Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 300005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int h, w, m;
	in2(h, w);in(m);
	
	vector<int> row[MAX];
	unordered_map<int, int> col;
	for(int i=0;i<m;i++) {
		int x, y;
		in2(x, y);
		row[x].PB(y);
		col[y]++;
	}
	
	unordered_map<int, int> :: iterator it = col.begin();
	set<pi> temp;
	while(it != col.end()) {
		temp.insert(MP(it->second, it->first));
		it++;
	}
	
	int ans = 0;
	for(int i=0;i<MAX;i++) {
		int rsz = row[i].size();
		if(rsz > 0) {
			for(int j=0;j<rsz;j++) {
				int curr = col[row[i][j]];
				temp.erase(temp.find(MP(curr, row[i][j])));
				temp.insert(MP(curr-1, row[i][j]));
			}
			
			pi maxi = *temp.rbegin();
			ans = max(ans, maxi.X + rsz);
			
			for(int j=0;j<rsz;j++) {
				int curr = col[row[i][j]];
				temp.erase(temp.find(MP(curr-1, row[i][j])));
				temp.insert(MP(curr, row[i][j]));
			}
		}
	}
	cout<<ans<<en;
}

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


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

int main(){
	
	map<string,int> a{
		{"SUN",7},
		{"MON",6},
		{"TUE",5},
		{"WED",4},
		{"THU",3},
		{"FRI",2},
		{"SAT",1}
	};
	string b; cin >> b;
	cout << a[b] << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<char> s(6);
    for(int i=0;i<6;i++)
    cin>>s[i];
    if(s[2]==s[3]&&s[1]==s[4]&&s[0]==s[5])
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  s+=s[0],s+=s[1];
  vector<int> v(n+2);
  rep(i,2){
    rep(j,2){
      v.clear();
      v.resize(n+2);
      v[0]=i,v[1]=j;
      for(int k=2;k<n+2;k++){
        v[k]=(v[k-2]^v[k-1]);
        if(s[k-1]=='x')v[k]=1-v[k];
      }
      if(v[0]==v[n] && v[1]==v[n+1]){
        rep(i,n){
          if(v[i]==0)cout << 'S';
          else cout << 'W';
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#define NIL -1
#define MAX 500001
using namespace std;

struct Node
{
    int key;
    Node *parent, *left, *right;
    Node(int ikey) : key(ikey), parent(nullptr), left(nullptr), right(nullptr) {}
};

Node *root;

void insert(Node *parent, int key) {
    if(root == nullptr) {
        root = new Node(key);
        return;
    }
    if(key <= parent->key) {
        if(parent->left == nullptr) {
            parent->left = new Node(key);
            return;
        }
        insert(parent->left, key);
    } else {
        if (parent->right == nullptr)
        {
            parent->right = new Node(key);
            return;
        }
        insert(parent->right, key);
    }
}

void inorder(Node *node) {
    if(node == nullptr) return;
    inorder(node->left);
    cout << " " << node->key;
    inorder(node->right);
}

void preorder(Node *node) {
    if(node == nullptr) return;
    cout << " " << node->key;
    preorder(node->left);
    preorder(node->right);
}

bool find(Node *node, int key) {
    if(node == nullptr) return false;
    if(node->key == key) return true;
    return find(node->left, key) || find(node->right, key);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(s == "insert") {
            int key;
            cin >> key;
            insert(root, key);
        } else if(s == "find") {
            int key;
            cin >> key;
            if (find(root, key)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else if(s == "print") {
            inorder(root);
            cout << "\n";
            preorder(root);
            cout << "\n";
        }
    }

}



Measured memory_bytes: 26584
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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 UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto 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)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int d;
int main() {
	int a,b;cin>>a>>b;
	char mark[5] = {'H', 'S', 'T', 'M'};
	int pl[4] = {1867, 1911, 1925, 1988};
	switch(a){
	case 0:
		if(b<1912)d=3, b-=1867;
		else if(b<1926)d=2, b-=1911;
		else if(b<1989)d=1, b-=1925;
		else b-=1988;
		cout << mark[d] << b;
		break;
	default:
		cout << b+pl[a-1];
		break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
  
        StringBuilder buf = new StringBuilder();
        for(int i = 3; i <= n; i++) {
            buf.append(checkNum(i) || include3(i) ? " " + i : "");
        }
        
        System.out.println(buf.toString());
    }
    
    private static boolean checkNum(int i) {
        return i % 3 == 0;
    }
    
    private static boolean include3(int i) {
        if(i % 10 == 3) {
            return true;
        }
        
        i /= 10;
        if(i == 0) {
            return false;
        } 
        return include3(i);
    }
}


Measured memory_bytes: 27932
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> v1;
  rep(i,0,n){
    ll a;
    cin>>a;
    v1.pb(a);
  }
  sort(all(v1));
  vector<pair<ll,ll> > vp;
  vector<ll> v2;
  rep(i,0,m){
    ll b,c;
    cin>>b>>c;
    vp.pb(mp(c,b));
  }
  sort(all(vp));
  reverse(all(vp));
  rep(i,0,vp.sz){
    ll b = vp[i].se;
    ll c = vp[i].fi;
    rep(j,0,b){
      if(v2.sz>100100)break;
      v2.pb(c);
    }
  }
  sort(all(v2));
  reverse(all(v2));
  rep(i,0,100100){
    v2.pb(0);
  }
  ll ans = 0;
  rep(i,0,n){
    ans += max(v1[i],v2[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5616
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int const N = 100000;

int main(){
    string s;
    cin>>s;
    int size = s.size();
    vector<int> v(size);
    int ct = 0;
    rep(i, size){
        if(s[i]=='R') ct++;
        else{
            v[i-1] += (ct+1)/2;
            v[i] += ct/2;
            ct = 0;
        }
    }
    ct = 0;
    for(int i=size;i>=0;--i){
        if(s[i]=='L') ct++;
        else{
            v[i+1] += (ct+1)/2;
            v[i] += ct/2;
            ct = 0;
        }
    }
    rep(i,size) {cout << v[i] << " ";}
    cout << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 105;
const int K = 200005;
int32_t main()
{
	fio();
	int n,k;
	cin>>n>>k;
	int a[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	int ans[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			ans[i][j]=0;
	for(int i=0;i<n;i++)
		ans[i][i]=1;
	while(k>0)
	{
		int temp2[n][n];
		if(k%2)
		{
			for(int x=0;x<n;x++)
				for(int y=0;y<n;y++)
				{
					temp2[x][y]=0;
					for(int z=0;z<n;z++)
					{
						temp2[x][y]+=(ans[x][z]*a[z][y]);
						temp2[x][y]%=MOD;
					}
				}
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
				{
					//ans[i][j]+=temp2[i][j];
					ans[i][j]=temp2[i][j];
				}
		}
		for(int x=0;x<n;x++)
			for(int y=0;y<n;y++)
			{
				temp2[x][y]=0;
				for(int z=0;z<n;z++)
				{
					temp2[x][y]+=(a[x][z]*a[z][y])%MOD;
					temp2[x][y]%=MOD;
				}
			}

		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				//ans[i][j]+=temp2[i][j];
				a[i][j]=temp2[i][j];
			}
		k=k/2;
	}
	int c=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			c+=ans[i][j];
			c%=MOD;
		}
	cout<<c<<endl;
}



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

using namespace std;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n + 1, INF);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i=2;i<=n;++i) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));

    cout << dp[n - 1] << endl;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    punches = [[False for i in range(3)] for i in range(3)]
    for step in range(N):
        for i in range(3):
            for j in range(3):
                if A[i][j] == b[step]:
                    punches[i][j] = True
    for i in range(3):
        hasFalse = False
        for j in range(3):
            if not punches[i][j]:
                hasFalse = True
                break
        if not hasFalse:
            print("Yes")
            return
    for i in range(3):
        hasFalse = False
        for j in range(3):
            if not punches[j][i]:
                hasFalse = True
                break
        if not hasFalse:
            print("Yes")
            return
    if punches[0][0] and punches[1][1] and punches[2][2]:
        print("Yes")
        return
    if punches[0][2] and punches[1][1] and punches[2][0]:
        print("Yes")
        return
    print("No")
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


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

int main()
{
  string s;
  cin >> s;
  if(s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
                                                                                               
  
  return 0;
}


Measured memory_bytes: 3604
N, M = map(int, input().split())
afs = []
for i in range(M):
  a, b = map(int, input().split())
  cs = map(int, input().split())
  f = 0
  for c in cs:
    f = f|(1<<(c-1))
  afs.append((a, f))
dp = [{} for i in range(M+1)]
dp[0][0] = 0
for i in range(M):
  d = dp[i]
  a0, f0 = afs[i]
  d2 = {}
  for f in d:
    d2[f] = d[f]
  for f in d:
    f2 = f|f0
    a2 = d[f]+a0
    d2[f2] = a2 if f2 not in d2 else min(d2[f2], a2)
  dp[i+1] = d2
#print(dp)
if (1<<N)-1 in dp[M]:
  r = dp[M][(1<<N)-1]
else:
  r = -1
print(r)


Measured memory_bytes: 224004
def main():
    N = int(input())
    num_list = [list(map(int, input().split())) for _ in range(N)]

    for i in range(N):
        t = num_list[i][0]
        xy = num_list[i][1] + num_list[i][2]
        if t < num_list[i][1] or t < num_list[i][2]:
            print('No')
            exit()
        if t < xy:
            print('No')
            exit()
        if t % 2 == 0 and xy % 2 != 0:
            print('No')
            exit()
        if t % 2 != 0 and xy % 2 == 0:
            print('No')
            exit()


    print('Yes')

if __name__ == '__main__':
    main()


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    string s;
    int k;
    cin >> s >> k;
    int cta = 0;
    rep(i, min((int)s.length(), k)) if (s[i] == '1') cta++;
    if (cta == k)
        cout << 1 << endl;
    else
    {
        rep(i, k)
        {
            if (s[i] != '1')
            {
                cout << s[i] << endl;
                return;
            }
        }
    }
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3644
#include <stdio.h>
 
#define min(a,b) ((a) < (b) ? (a) : (b))
#define MAX_V 100
#define INF 1e9
 
int V;
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
int used[MAX_V];
 
int prim() {
  int i,res,v,u;
 
  for (i = 0 ; i < V ; i++) {
    mincost[i] = INF;
    used[i] = 0;
  }
 
  mincost[0] = 0;
  res = 0;
 
  while (1) {
    v = -1;
 
    for (u = 0 ; u < V ; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
    v = u;
      }
    }
 
    if (v == -1) {
      break;
    }
    used[v] = 1;
    res += mincost[v];
 
    for (u = 0 ; u < V ; u++) {
      if (cost[v][u] != -1) {
    mincost[u] = min(mincost[u],cost[v][u]);
      }
    }
 
  }
 
  return res;
}
 
int main() {
  int i,j;
   
  scanf("%d" ,&V);
  for (i = 0 ; i < V ; i++) {
    for (j = 0 ; j < V ; j++) {
      scanf("%d" ,&cost[i][j]);
    }
  }
 
  printf("%d\n" ,prim());
 
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
using namespace std;



int main() {
	long long int n, m, d = 0, q, s[200006] = {}, a[200006] = {}, b[200006] = {}, leng = 0, goal, two = 0, three = 0, temp = 0;

	cin >> n>>m;
	for (int i = 0; i < m; i++) {
		cin >> a[i]>>b[i];
		if (a[i] == 1) { s[b[i]]++; }
		if (a[i] == n) { s[b[i]]+=2; }
		if (b[i] == 1) { s[a[i]]++; }
		if (b[i] == n) { s[a[i]]+=2; }
	}

	for (int i = 1; i <= n; i++) {
		if (s[i] == 3) { cout << "POSSIBLE"; return 0; }
	}
	cout << "IMPOSSIBLE";
}

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

int main(){
  ll N,S=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
    S += A.at(i);
  }
  ll m = S,sum = 0;
  rep(i,N){
    sum += A.at(i);
    m = min(m, abs(sum-(S-sum)));
  }
  cout << m << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 5e3+5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	string res;
	while(n){
		if(n%26 == 0){
			res += 'z';
			n -= 26;
		}
		else res += n%26 + 'a' - 1;
		n /= 26;
	}
	reverse(res.begin(), res.end());
	cout<<res;
}

Measured memory_bytes: 3652
/*
created by Sanyam Singhal
/*/

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

void solve(){
  ll n,w; cin>>n>>w;
  vll weights(n), profits(n);

  loop(i, 0, n){
    cin>>weights[i]>>profits[i];
  }

  ll dp[n+1][w+1];
  memset(dp, 0, sizeof(dp));

  loop(i, 1, n+1){
    loop(j, 1, w+1){
      if(weights[i-1]<=j){
        dp[i][j] = dp[i-1][j-weights[i-1]] + profits[i-1];
      }
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
    }
  }

  cout<<dp[n][w];

  return;
}

int main(){

  fastIO;
  // take_fileIO();

  solve();

  return 0;
}

Measured memory_bytes: 79232
/*
[abc116] A - Right Triangle
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int a, b, c;

ll solve() {
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {
    cin >> a >> b >> c;

    cout << solve() << endl;

    return 0;
}


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

int main()
{
  uint64_t h, n = 1, r = 0;
  cin >> h;
  while (1)
  {
    r += n;
    if (h <= 1)
    {
      break;
    }
    h /= 2;
    n *= 2;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N;
	cin >> N;
	vl A(N);
	rep(i, N)
		cin >> A[i];
	ll ans = -InfLL;
	if (N % 2 == 0) {
		vl Asum(N + 2, 0);
		rep(i, N) {
			Asum[i + 2] = Asum[i] + A[i];
		}
		rep(i, N + 1) {
			if (i % 2 == 0)
				ans = max(ans, Asum[i] + Asum[N + 1] - Asum[i + 1]);
		}
	}
	else {
		vl Asum(N + 2, 0);
		rep(i, N) {
			Asum[i + 2] = Asum[i] + A[i];
		}
		vl ansL(N, 0);
		vl ansR(N, 0);
		rep(i, N) {
			if (i % 2 == 1)
				ansL[i] = Asum[i + 1] - Asum[i + 2];
		}
		rep(i, N) {
			if (i % 2 == 1) {
				ansR[i] -= Asum[N] - Asum[i];
				ansR[i] += (Asum[N + 1] - Asum[i + 1]);
			}
		}
		vl ansLmax(N + 2, 0);
		vl ansRmax(N + 2, 0);
		rep(i, N) {
			if (i % 2 == 1) {
				ansLmax[i + 2] = max(ansLmax[i], ansL[i]);
			}
		}
		rrep(i, N) {
			if (i % 2 == 1) {
				ansRmax[i] = max(ansRmax[i + 2], ansR[i]);
			}
		}
		rep(i, N + 1) {
			if (i % 2 == 1) {
				ll anstmp = Asum[N];
				anstmp += ansLmax[i];
				anstmp += ansRmax[i];
				ans = max(ans, anstmp);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12760
# https://atcoder.jp/contests/abc151/tasks/abc151_e

def calc(x,y):
    a = fac[x]
    b = fac[y]
    c = fac[x-y]
    ret = ( (a%p)*pow(b,p-2,p)*pow(c,p-2,p))%p
    return ret

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
p=10**9+7

fac=[1]
for i in range(1,N+1):
    fac.append( (fac[-1]*i)%p )
#print(fac)

ans=0

for i in range(N):
    if i<=N-K:
        nokori = N-1-i
        kumi = calc(nokori,K-1)
        ans -= (A[i]*kumi)%p
    if i>=K-1:
        nokori = i
        kumi = calc(nokori,K-1)
        ans += (A[i]*kumi)%p
        
print(ans%p)

#for L in range(N-K+1):
#    for R in range(L+K-1,N):
#        if L==R:
#            tmp=0
#            diff=0
#            #print(L,R,diff)
#        elif L+(K-1)==R:
#            diff= A[R]-A[L]
#            ans += diff
#            #print(L,R,diff)
#        else:
#            tmp = calc(R-L-1,K-2)
#            diff= tmp*(A[R]-A[L])
#            ans += diff            
#            #print(L,R,diff)
#        ans %=p

Measured memory_bytes: 20320
import           Control.Applicative
import           Control.Monad.State

newtype Stack a = Stack [a]
    deriving (Read, Show)

push :: a -> State (Stack a) ()
push a = do
    s <- get
    case s of
        Stack []     -> put (Stack [a])
        Stack (x:xs) -> put (Stack (a:x:xs))
    return ()

pop :: State (Stack a) a
pop = do
    s <- get
    case s of
        Stack [] -> error "empty stack"
        Stack (x:xs) -> do
            put (Stack xs)
            return x

rpn :: [String] -> State (Stack Int) Int
rpn [] = pop
rpn (x:xs)
    | x == "+"  = calc (+) >> rpn xs
    | x == "-"  = calc (-) >> rpn xs
    | x == "*"  = calc (*) >> rpn xs
    | x == "/"  = calc div >> rpn xs
    | otherwise = do
        push $ read x
        rpn xs
  where
    calc op = do
        b <- pop
        a <- pop
        push (op a b)

main = do
    xs <- words <$> getLine :: IO [String]
    print $ evalState (rpn xs) (Stack [])



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

int main() {
  int X;
  cin >> X;
  int N;
  cin >> N;
  int D = 0;
  vector<int> A(N);
  int K = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if(A.at(i) == X){
      D = 1;
    }
  }
  if(D == 0){
    cout << X;
  }
  else{
    D = 0;
    while(K == 0){
      D = D + 1;
      K = 0;
      for(int j = 0; j < N; j++){
        if(A.at(j) == X - D){
          K = 1;
        }
      }
      if(K == 0){
        cout << X - D;
        K = 1;
      }
      else{
        K = 0;
        for(int k = 0; k < N; k++){
          if(A.at(k) == X + D){
            K = 1;
          }
        }
        if(K == 0){
          cout << X + D;
          K = 1;
        }
        else{
          K = 0;
        }
      }
    }
  }
}

Measured memory_bytes: 3564
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# 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;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, k;
int dp[(1 << 14)];

void upd (int &a, int b) {
	if (a == -1 || a > b) a = b;
}


int main () {
   SpeedForce;
   cin >> n >> k;
   for (int m = 1; m < (1 << n); m ++)
   	dp[m] = -1;
   for (int i = 1; i <= k; i ++) {
   	int a, b, nw = 0;
   	cin >> a >> b;
   	for (int i = 0; i < b; i ++) {
   		int x;
   		cin >> x;
   		x--;
   		nw |= (1 << x);
   	}

   	for (int m = (1 << n) - 2; m >= 0; m --) if(dp[m] != -1) {
   		upd(dp[m | nw], dp[m] + a);
   	} 
   }
   cout << dp[(1 << n) - 1];
   	
	
   return Accepted;
}

// B...a

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		String[] S = new String[N];
		Arrays.setAll(S, $ -> sc.get());
		int ac = 0, wa = 0, tle = 0, re = 0;
		for (String s : S) {
			switch (s) {
				case "AC":
					ac++;
					break;
				case "WA":
					wa++;
					break;
				case "TLE":
					tle++;
					break;
				case "RE":
					re++;
					break;
			}
		}
		System.out.printf("AC x %d%nWA x %d%nTLE x %d%nRE x %d%n", ac, wa, tle, re);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 48792
#include<stdio.h>

void main(){
	char a[10], b[10];
	scanf("%s%s", a, b);
	if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        String s = in.next();
        
        if (s.length() == 1) {
            if (c(s)) {
                out.println(1);
            } else {
                out.println(0);
            }
            return;
        }

        int max = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            for (int j = i + 1; j <= s.length(); j++) {
                String x = s.substring(i, j);
                if (c(x)) {
                    max = Math.max(max, x.length());
                }
            }
        }

        out.println(max);
    }

    boolean c(String s) {
        s = s.replace("A", "");
        s = s.replace("T", "");
        s = s.replace("C", "");
        s = s.replace("G", "");
        return s.length() == 0;
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,q;
    cin>>n>>q;
    vector<vector<int>> v1(n+2);
    vector<int> ans(n+2),par(n+2);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        v1[a].push_back(b);
        v1[b].push_back(a);        
    }
    for(int i=0;i<q;i++){
        int a,b;
        cin>>a>>b;
        ans[a]+=b;
    } 
    //BFS
    vector<int> visit(n+2);
    queue<int> que;
    que.push(1);
    visit[1]=1;
    while(que.empty()!=1){
        int tmp=que.front(); 
        que.pop();
        for(int j=0;j<v1[tmp].size();j++){
            if(visit[v1[tmp][j]]==0){
                que.push(v1[tmp][j]);
                visit[v1[tmp][j]]=1;
                par[v1[tmp][j]]=tmp;
            }
        }
    }

    for(int i=1;i<=n;i++){
        ans[i]+=ans[par[i]];
        cout<<ans[i];
        if(i==n) break;
        else cout<<" ";
    }
    return 0;
}

Measured memory_bytes: 17140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
#include <cmath>
#include <utility>
//#include <pair>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)

int main(){
    int n,m;
    cin >> n >> m;
    vector<pii> vec;
    int a,b;

    rep(i,m){
        cin >> a >> b;
        vec.push_back({a,b});
    }

    sort(vec.begin(),vec.end(), 
        [](const pii pa, const pii pb){
            return pa.second < pb.second;
        }
    );
    
    int tmp = vec[0].second - 1;
    int ans = 1;
    reps(i,1,m){
        if(tmp < vec[i].first) {
            tmp = vec[i].second- 1;
            ans++;
        }
    }

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
    bool has(int x){
        while(x){ 
            if(x %10== 3){
              return true;
            }
            x/=10;
        }
        return false;
    }

    void call(int n){
        rep(i,n){
            if((i+1) %3 ==0 ||has(i+1)){
                cout<<" "<< i+1;
            }
        }
        cout<<endl;
    }
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int n;
    cin >>n;
    call(n);

 
}


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

int main() {
  string s,t;
  int counter = 0;
  int ans = 10000;
  cin >> s >> t;
  int lt = t.length();
  int ls = s.length();
  
  for(int i = 0; i < ls-lt+1; i++){
    counter = 0;
    for(int j = 0; j < lt; j++){
      if(s[i+j] != t[j]) counter++;
    }
    ans = min(counter,ans);
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3616
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;
 
    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5560